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 |
|
under2811
Constraint Violating Yak Guru
366 Posts |
Posted - 2006-03-02 : 08:37:08
|
| hi..why this SP is not working that giving me error likeServer: Msg 2714, Level 16, State 1, Procedure test_E, Line 12There is already an object named '#emp' in the database.my one of the developer used this every where... what should i do if i dont wanna to change any of the code...i wanna some how work this SP...create proc test_Easselect * into #empfrom (select * from emp) pselect * from #empdrop table #empselect * into #empfrom (select * from dept) pselect * from #empdrop table #empT.I.APapillon |
|
|
p.shaw3@ukonline.co.uk
Posting Yak Master
103 Posts |
Posted - 2006-03-02 : 08:40:44
|
| Open Query Analyser making sure you are in the same Database as your Stored Procedure and run:-drop table #empThen try your Stored Procedure again.Pat. |
 |
|
|
JoeNak
Constraint Violating Yak Guru
292 Posts |
Posted - 2006-03-02 : 08:41:00
|
| Is this the actual code for the proc? |
 |
|
|
under2811
Constraint Violating Yak Guru
366 Posts |
Posted - 2006-03-02 : 08:47:04
|
| hi..its just sample to understand....i opened another QA and i was in the same database as my SP is..but when i ran drop table #emp i got this errorServer: Msg 3701, Level 11, State 5, Line 1Cannot drop the table '#emp', because it does not exist in the system catalog.T.I.APapillon |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2006-03-02 : 08:47:26
|
| [code]create proc test_Easselect * into #empfrom (select * from emp) pselect * from #empdrop table #empselect * into #empfrom (select * from dept) pselect * from #empdrop table #emp[/code]You can't use SELECT ... INTO #emp twice. The parser will not let you pass this. Change to insert ... select or use different temp table name----------------------------------'KH' |
 |
|
|
X002548
Not Just a Number
15586 Posts |
|
|
|
|
|