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 |
ggarza75
Yak Posting Veteran
50 Posts |
Posted - 2009-08-14 : 12:38:33
|
I'm trying to call a stored procedure within a stored procedure, but I keep getting a error stating "Incorrect syntax near '@caseobjid'" It's identifying the line where the SP is being called?Can a SP be called within an SP? I thought it could.Any help? Here's the code:--====================================CREATE PROCEDURE usp_sp1 @caseobjid int --THIS IS THE OBJID ID FROM THE TABLE_CASE TABLEASDECLARE @ERROR INTBEGIN TRANSACTIONINSERT INTO [server].[database].[DBO].[Table] (columns1, columns2)SELECT columns1, columns2FROM [server2].[database2].[DBO].[Table2]WHERE case = @caseobjid IF @@ERROR = 0 COMMIT TRANSACTIONELSE ROLLBACK TRANSACTIONBEGIN TRANSACTIONusp_archive_primcon_delete @caseobjidIF @@ERROR = 0 COMMIT TRANSACTIONELSE ROLLBACK TRANSACTION |
|
russell
Pyro-ma-ni-yak
5072 Posts |
Posted - 2009-08-14 : 14:10:06
|
CREATE PROCEDURE usp_sp1@caseobjid int --THIS IS THE OBJID ID FROM THE TABLE_CASE TABLEASDECLARE @ERROR INTBEGIN TRANSACTIONINSERT INTO [server].[database].[DBO].[Table] (columns1, columns2)SELECT columns1, columns2FROM [server2].[database2].[DBO].[Table2]WHERE case = @caseobjidIF @@ERROR = 0COMMIT TRANSACTIONELSE ROLLBACK TRANSACTIONBEGIN TRANSACTIONEXEC usp_archive_primcon_delete @caseobjidIF @@ERROR = 0COMMIT TRANSACTIONELSE ROLLBACK TRANSACTION |
|
|
russell
Pyro-ma-ni-yak
5072 Posts |
Posted - 2009-08-14 : 14:10:54
|
why the 2 seperate transactions? seems unnecessary to me |
|
|
ggarza75
Yak Posting Veteran
50 Posts |
Posted - 2009-08-14 : 15:00:04
|
I did have it under one sp, but what I'm trying to do did not work. So I've been testing it out by breaking it apart. |
|
|
|
|
|