Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
petek
Posting Yak Master
192 Posts |
Posted - 2008-08-21 : 11:18:10
|
High all,firstly thanks for looking.Is there a way to create a table after running a stored procedure.Bsasically where a stored procedure is run i need to create a table but when the table is run again it needs to create a new table (same structure but different name)can this be done.Thanks in advance.Kind RegardsPete. |
|
jhocutt
Constraint Violating Yak Guru
385 Posts |
Posted - 2008-08-21 : 11:35:50
|
if exists (select * from dbo.sysobjects where id = object_id(N'[fred]') and OBJECTPROPERTY(id, N'IsUserTable') = 1) declare @SQL varchar(255) set @SQL='fred_'+ replace(convert(varchar(25),GetDate(),109), ' ','_') exec sp_rename fred, @SQLGOcreate table fred (col1 int)"God does not play dice" -- Albert Einstein"Not only does God play dice, but he sometimes throws them where they cannot be seen." -- Stephen Hawking |
 |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-08-21 : 13:28:16
|
Do you mean you need to create a new table for each procedure run? why do you want to do it? |
 |
|
petek
Posting Yak Master
192 Posts |
Posted - 2008-08-22 : 04:42:19
|
basically when i run the code i need to store the results in some format, i am thinking it would be better to store the data in a excel file.is there a way to do that. i will run three stored procedures and the data from each procedure needs to go a sperate excel worksheet in one file. but when its run again rename the new sheet.Kind RegardsPete. |
 |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-08-22 : 04:56:53
|
quote: Originally posted by petek basically when i run the code i need to store the results in some format, i am thinking it would be better to store the data in a excel file.is there a way to do that. i will run three stored procedures and the data from each procedure needs to go a sperate excel worksheet in one file. but when its run again rename the new sheet.Kind RegardsPete.
you can store the results onto excel sheept using OPENROWSET or any other methods as stated in below linkhttp://www.mssqltips.com/tip.asp?tip=1202 |
 |
|
|
|
|