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 |
|
pssheba
Yak Posting Veteran
95 Posts |
Posted - 2009-11-10 : 04:56:00
|
Hi everyone,If i run the following code :IF EXISTS(SELECT * FROM sysobjects WHERE name='to_pros')/*IF OBJECT_ID("to_pros") IS NOT NULL*/DROP TABLE to_prosGOSELECT * INTO to_prosFROM final_tableWHERELOWER(Date) NOT LIKE '%total%'every thing is fine. I run it again and again and everything is just fine. No error message !When that same code is part of a wider SP and I click the "Execute" button in the SSMS I get an error messagethat says:quote: Msg 2714, Level 16, State 6, Line 2There is already an object named 'to_pros' in the database.
I know there is a table named: "to_pros" in the database but there also is a line telling the procedure todrop it !!!if any one finds out why i get that error i'll be grateful !Thanks |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2009-11-10 : 05:01:15
|
To drop the table manually before creating the SP will help.Once the SP is created, it will run fine. No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
pssheba
Yak Posting Veteran
95 Posts |
Posted - 2009-11-10 : 06:15:24
|
| Hi Webfred,Thanks.What if i run that procedure from another procedure ? What if this procedure runs automatically ?Thanks |
 |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2009-11-10 : 06:22:07
|
The posted problem only occurs while trying to create the procedure - not an runtime.But be sure to run this procedure only one at a time in the same database. No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2009-11-10 : 06:23:05
|
Do you know the difference between creating and executing a stored procedure? No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
pssheba
Yak Posting Veteran
95 Posts |
Posted - 2009-11-10 : 06:54:21
|
quote: Originally posted by webfred The posted problem only occurs while trying to create the procedure - not an runtime.But be sure to run this procedure only one at a time in the same database. No, you're never too old to Yak'n'Roll if you're too young to die.
It occcurs also when the SP is created. How can i run it if it is not created ? Why can i not run run it as many times as i wish ? |
 |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2009-11-10 : 07:35:37
|
This is working fine!--drop proc testcreate procedure testasif (Object_ID('testsptable') is not null)drop table testsptableselect 'test' as tst,4711 as tstid into testsptable where 1=1exec test No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
|
|
|
|
|