|
|
|
SSC Rookie
      
Group: General Forum Members
Last Login: Thursday, May 16, 2013 2:43 PM
Points: 33,
Visits: 164
|
|
Hello,
I'm Getting the following error when I run the below SQLCMD command and not sure how to resolve this issue:
C:\Test>sqlcmd -S localhost\TESTINSTANCE -i test.sql -v filepath=".\" Changed database context to 'TEST_DB'. Msg 137, Level 15, State 2, Server TOM\TESTINSTANCE, Line 18 Must declare the scalar variable "@indate".
Table EMP:
CREATE TABLE EMP (EMPID INT, EMPNAME VARCHAR(50), EMP_JOIN_DATE DATETIME);
Test.sql:
USE TEST_DB GO :r $(filePath)Upgrade_Script.sql :r $(filePath)Create_StoredProcedures.sql GO
Upgrade_Script.sql:
USE master --GO --50001 IF EXISTS(SELECT * FROM sys.messages WHERE message_id = 50001) BEGIN exec sp_dropmessage 50001 END --go PRINT '------------------------------------------------------------------------------------------------------------------------------------------------------------------' print ' End of Upgrade_Script ' PRINT '------------------------------------------------------------------------------------------------------------------------------------------------------------------' PRINT ' ' --GO
Create_StoredProcedures.sql:
CREATE PROCEDURE [TEST_DB].[dbo].[GetSP] @indate DateTime AS BEGIN SET NOCOUNT ON SELECT * FROM EMP WHERE EMP_JOIN_DATE > @indate; END --GO
Thanks!
|
|
|
|
|
Ten Centuries
      
Group: General Forum Members
Last Login: Today @ 7:27 AM
Points: 1,259,
Visits: 4,260
|
|
| I'm pretty sure you can't specify the entire three-part database name in a CREATE PROCEDURE call like that--if you change that to USE Test_DB and only specify the procedure name in the CREATE call, does it work?
|
|
|
|