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 |
|
swati
Starting Member
2 Posts |
Posted - 2003-04-30 : 01:01:57
|
| Hello,I am trying to run the replication script using a stored procedures where Iwill allow user to send databseName etc as the input parameters to theprocedure.The procedure then internally calls the system procedures requiredfor replication using the inout parameter values.When I trying to create theprocedure it gives me error as 'Must declare the variable '@databaseName'I am pasting the part of the code I am using ,Please tell me where I amgoing wrong and why this error is coming.create procedure spDynamicReplicationNew(@databaseName varchar(100) = 'N%',@publication varchar(100),@snapshotName varchar(100),@tableName varchar(50))AS-- Enabling the replication database--use masterGOuse[master]exec sp_replicationdboption @dbname = @databaseName ,@optname = N'merge publish', @value = N'true'GOThanks in advanceRegards,Swati |
|
|
ValterBorges
Master Smack Fu Yak Hacker
1429 Posts |
Posted - 2003-04-30 : 02:49:58
|
quote: GO is not a Transact-SQL statement; it is a command recognized by the osql and isql utilities and SQL Query Analyzer.SQL Server utilities interpret GO as a signal that they should send the current batch of Transact-SQL statements to SQL Server. The current batch of statements is composed of all statements entered since the last GO, or since the start of the ad hoc session or script if this is the first GO. SQL Query Analyzer and the osql and isql command prompt utilities implement GO differently. For more information, see osql Utility, isql Utility, and SQL Query Analyzer.
Your stored proc was being created to do nothing.Once you removed the GO you would have gotten this errorServer: Msg 154, Level 15, State 1, Procedure spDynamicReplicationNew, Line 12a USE database statement is not allowed in a procedure or trigger.The key is to use the Catalog.Schema.Object Convention for calling the sproc.There that's all better now.create procedure spDynamicReplicationNew ( @databaseName varchar(100) = 'N%', @publication varchar(100), @snapshotName varchar(100), @tableName varchar(50) ) AS exec master..sp_replicationdboption @dbname = @databaseName , @optname = N'merge publish', @value = N'true' |
 |
|
|
|
|
|
|
|