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 |
|
reddymade
Posting Yak Master
165 Posts |
Posted - 2007-02-15 : 22:41:50
|
| I am trying to create the following stored procedure, getting an error message saying i cannot use the use database inside the stored proc:*************************************************CREATE PROCEDURE [dbo].[USP_sMailSum]WITH ENCRYPTIONASDECLARE @ErrorCode intSET NOCOUNT ONSELECT @ErrorCode = @@ErrorIF @ErrorCode = 0BEGIN use Database1 exec USP_sSendMail use Database2 exec USP_sSendMail SELECT @ErrorCode = @@ErrorENDSET NOCOUNT OFFRETURN @ErrorCode***************************************************Thank you very much for the information. i have a sql agent job there i would likle to call this stored proc. |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2007-02-15 : 23:12:45
|
[code]use Database1exec Database1.dbo.USP_sSendMailuse Database2exec Database2.dbo.USP_sSendMail[/code] KH |
 |
|
|
Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)
7020 Posts |
Posted - 2007-02-15 : 23:13:39
|
| The message seems clear to me. You can't have a USE DATABASE command in a stored procedure.CODO ERGO SUM |
 |
|
|
|
|
|