CanNeverThinkOfaName
Programmer
DROP TABLE #temp
CREATE TABLE #temp ([User] nvarchar(100))
INSERT INTO #temp
SELECT [User]
FROM tblStatsUserDetailed
GROUP BY [User]
DECLARE @StatsDate nvarchar(10)
SET @StatsDate = 'SQL'
ALTER TABLE #temp ADD @StatsDate nvarchar(10) null
I'm basically trying to add the column name 'SQL' to the table using a variable.
It won't accept using a variable in the syntax
The reason I'm doing it this way is I will be cursoring throught a SQL Statement and using the result (eg 23/03/2005) and making that the column name so I will need to use a variable in the ALTER statement (So the table will now say User as Col1 and 23/03/2005 as Col2 etc)
is it possible please?
thanks
CREATE TABLE #temp ([User] nvarchar(100))
INSERT INTO #temp
SELECT [User]
FROM tblStatsUserDetailed
GROUP BY [User]
DECLARE @StatsDate nvarchar(10)
SET @StatsDate = 'SQL'
ALTER TABLE #temp ADD @StatsDate nvarchar(10) null
I'm basically trying to add the column name 'SQL' to the table using a variable.
It won't accept using a variable in the syntax
The reason I'm doing it this way is I will be cursoring throught a SQL Statement and using the result (eg 23/03/2005) and making that the column name so I will need to use a variable in the ALTER statement (So the table will now say User as Col1 and 23/03/2005 as Col2 etc)
is it possible please?
thanks