根据‘—’,截取字符串


--根据‘——’,截取字符串

			declare @FBillNo varchar(20)  --
			declare @FBillN_SSSSS varchar(20)  --
			declare @FBillN_SSSSS_1 varchar(20)  --
				
				set @FBillNo='1105202005070001FY-1'
					
			-------------------按照‘-’截取大批次号-----------------------
		select @FBillN_SSSSS=substring(@FBillNo,1,charindex('-',@FBillNo)-1)
		select 	@FBillN_SSSSS_1=substring(@FBillN_SSSSS,LEN(@FBillN_SSSSS)-1,2)	
		if(@FBillN_SSSSS_1='FY')
			begin
				set @FBillN_SSSSS=substring(@FBillN_SSSSS,1,LEN(@FBillN_SSSSS)-2)
			end
		else
			begin
				set @FBillN_SSSSS=@FBillN_SSSSS
			end
			-------------------按照‘-’截取大批次号-----------------------	









 

你可能感兴趣的:(sqlserver)