Friday, 19 July 2013

sql varchar parameter convert in int on run time for checking IS NULL then value get in int like 0

declare @dd varchar(98)
set @dd='100'
select
case when @dd like '%[^0-9]%' 
        then 0  else @dd end

            declare @tt varchar(98)
            declare @AMFIcodeP varchar(98)
            set @AMFIcodeP='t44'
            declare @AMFIcodec varchar(98)
            set @AMFIcodec=3453
            declare @AMFIcodett int
            set @tt=@AMFIcodeP + @AMFIcodec
            if( @tt  like '%[^0-9]%' )
            set @tt =0
            set @AMFIcodett =CAST( @tt as int)
            print @AMFIcodett 

No comments:

Post a Comment