I need to loop through a table (Table1) and as it goes through each single record to concatenate 3 columns (date, time and code) it has to create a unique column(Primary Key) .
1) Is this a proper of looping on row of a table?
2) why am I getting error as following?
Msg 4104, Level 16, State 1, Line 11
The multi-part identifier "Table1.Date" could not be bound.
Msg 4104, Level 16, State 1, Line 12
The multi-part identifier "Table1.Time" could not be bound.
Msg 4104, Level 16, State 1, Line 13
The multi-part identifier "Table1.code" could not be bound.
while (select count(*) from Table1) > 0
declare @dt as varchar(10)
declare @ti as varchar(11)
declare @code as varchar(11)
set @dt = Table1.Date
set @ti = Table1.Time
set @code = Table.code
set @dt = REPLACE(@ti, '/','')
set @ti = REPLACE(@ti, ':','')
set @code = REPLACE(code, '.','')
select comb = @code + @dt + @dt