Hi!
I would like to create a table with a variable table name on the fly.. something like this
select * into mytable & suser_sname() from etc...
Any ideas?
Printable View
Hi!
I would like to create a table with a variable table name on the fly.. something like this
select * into mytable & suser_sname() from etc...
Any ideas?
While I'm sure that there is a more efficient method (I'm too tired to think of it now), you could do the following:
If you are using SQL Server 2000, you could look into creating functions to create the initial table and to return data from the newly created table.Code:Declare @sql varchar(8000)
Set @sql = "Select * Into myTable" + suser_sname() + " From ..."
Exec (@sql)
Could not get it to work
set @QueryString="select * into tblAdhChartErrors" + host_name() + " from #tblAdhChartErrors"
exec (@QueryString)
...