Hi
I'm trying to create a temporary table that's made up of a number of dynamic columns, but I can't get it working.
This is what I've got so far
DECLARE @LT varchar(100)
SET NOCOUNT ON
CREATE TABLE #AdminSummary
(
UserID int null
)
DECLARE cursor_lt CURSOR FOR
SELECT lt_name FROM lt WHERE loc_id = @LocID
OPEN cursor_lt
FETCH NEXT FROM cursor_lt INTO @LT
WHILE @@fetch_status = 0
BEGIN
ALTER TABLE #AdminSummary ADD @LT varchar(100) NULL
GO
FETCH NEXT FROM cursor_lt INTO @LT
END
CLOSE cursor_lt
DEALLOCATE cursor_lt
Can anyone help?
Cheers
Lbob
I'm trying to create a temporary table that's made up of a number of dynamic columns, but I can't get it working.
This is what I've got so far
DECLARE @LT varchar(100)
SET NOCOUNT ON
CREATE TABLE #AdminSummary
(
UserID int null
)
DECLARE cursor_lt CURSOR FOR
SELECT lt_name FROM lt WHERE loc_id = @LocID
OPEN cursor_lt
FETCH NEXT FROM cursor_lt INTO @LT
WHILE @@fetch_status = 0
BEGIN
ALTER TABLE #AdminSummary ADD @LT varchar(100) NULL
GO
FETCH NEXT FROM cursor_lt INTO @LT
END
CLOSE cursor_lt
DEALLOCATE cursor_lt
Can anyone help?
Cheers
Lbob