I am trying to set a couple of variables to equal the field values of the current record so I can process that information. I put together sample code that creates a temp table and has 2 attributes (animal & breed) and I would like to set the variables myAnimal and myBreed accordingly based on row number and the display them.
Can someone assist assigning and displaying the variables?
Code:
create table #myTable (animal varchar(10), type varchar(10))
insert into #myTable values ('Dog','Pug')
insert into #myTable values ('Cat','Siamese')
insert into #myTable values ('Bird','Robin')
DECLARE @Counter INT
SET @Counter=1
DECLARE @myAnimal as VARCHAR(10)
DECLARE @mybreed as VARCHAR(10)
WHILE ( @Counter <= 3)
BEGIN
-- Would like to set @myAnimail variable with current record. The first would be dog, next cat, next Bird
-- Would like to set @@mybreed variable with current record. The first would be pug, next Siamese, next Robin
-- Then display the variables (@myAnimails & myBreed)
Print 'Number ' + CAST(@Counter AS NVARCHAR(100))
SET @Counter = @Counter + 1
END
drop table #myTable
Jim