|
-
May 26th, 2004, 02:22 PM
#1
Thread Starter
Fanatic Member
Select into
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?
-
May 26th, 2004, 03:08 PM
#2
Fanatic Member
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:
Code:
Declare @sql varchar(8000)
Set @sql = "Select * Into myTable" + suser_sname() + " From ..."
Exec (@sql)
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.
Chris
Master Of My Domain
Got A Question? Look Here First
-
May 26th, 2004, 04:21 PM
#3
Thread Starter
Fanatic Member
Tried that..
Could not get it to work
set @QueryString="select * into tblAdhChartErrors" + host_name() + " from #tblAdhChartErrors"
exec (@QueryString)
...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|