April 27, 2012 at 12:24 am
Hi,
I do not know if I understand correctly but try this:
Set @c = @a * 1000 + @b;
Hope this helps.
April 27, 2012 at 12:29 am
This is a workaround to your requirement:
declare @a varchar(10), @b varchar(10), @c varchar(10), @d varchar(10) = '00'
set @a='1'
set @b='2'
Set @c=+@a+@d+@b
Select @c
set @a=112
set @b=2
Set @c=+@a+@d+@b
Select @c
Hope this helps.
April 27, 2012 at 12:36 am
Thank you
Vinu Vijayan
Imoveis em Guarulhos
Imoveis em Guarulhos its not working in some case..
Vinu Vijayan data type is int only.
Regards
Guru
April 27, 2012 at 12:39 am
imex (4/27/2012)
Hi,I do not know if I understand correctly but try this:
Set @c = @a * 1000 + @b;
Hope this helps.
Yes. If you want "@c" to be calculated then you can use imex's method....or else if you want to stuff the 0s in between the variables you can use my method.
This is a variation of my method when you can keep the variables as "int" and later cast them as varchar:
declare @a int ,@b int,@c varchar(10), @d int = 0
set @a=1
set @b=2
Set @c=+Cast(@a As varchar)+Cast(@d As varchar)+Cast(@d As varchar)+Cast(@b As varchar)
Select @c
set @a=112
set @b=2
Set @c=+Cast(@a As varchar)+Cast(@d As varchar)+Cast(@d As varchar)+Cast(@b As varchar)
Select @c
Viewing 5 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply