Hi, Is there a way to pass the value of combination variable to another variable? I guess better of with a simple code that I wrote...
DECLARE @intFlag INT
DECLARE @taxdepn1 varchar(1) = 'A'
,@taxdepn2 varchar(1) = 'B'
,@taxdepn3 varchar(1) = 'C'
,@taxdepn4 varchar(1) = null --'D' `
DECLARE @xxx varchar(1000);
SET @intFlag = 1
WHILE (@intFlag <=4)
BEGIN
set @xxx = '@taxdepn'+cast(@intFlag as CHAR) ;
-- Here, I want to get the actual value of @Taxdepn1 to @TaxDepn4
if @xxx is not null
begin
print 'do something for '+@xxx
end
set @intFlag = @intFlag+1 ;
End
Expected output
do something for A
do something for B
do something for C
I really appreciate any help.
Thanks.
Elmer