sql script
-
Hi All, I have created two databases Test1 and Test2. For one database(Test1) I got the latest version of the code, created the deployement script and deployed the changes to the db.For the other database(Test2) I need to run the deployment script which got created form the Test1 DB.I tried to run the script but my db is not supporting..I get the following errors.. Msg 102, Level 15, State 1, Line 1 Incorrect syntax near ':'. Msg 102, Level 15, State 1, Line 1 Incorrect syntax near ':'. Msg 50000, Level 16, State 127, Line 4 You cannot deploy this update script to target INP-xx. The database for which this script was built, Test2, does not exist on this server. Msg 911, Level 16, State 1, Line 1 Database '$(DatabaseName)' does not exist. Make sure that the name is entered correctly. Can Some one please help me out
-
Hi All, I have created two databases Test1 and Test2. For one database(Test1) I got the latest version of the code, created the deployement script and deployed the changes to the db.For the other database(Test2) I need to run the deployment script which got created form the Test1 DB.I tried to run the script but my db is not supporting..I get the following errors.. Msg 102, Level 15, State 1, Line 1 Incorrect syntax near ':'. Msg 102, Level 15, State 1, Line 1 Incorrect syntax near ':'. Msg 50000, Level 16, State 127, Line 4 You cannot deploy this update script to target INP-xx. The database for which this script was built, Test2, does not exist on this server. Msg 911, Level 16, State 1, Line 1 Database '$(DatabaseName)' does not exist. Make sure that the name is entered correctly. Can Some one please help me out
sindhuan wrote:
Can Some one please help me out
So there are errors for the first four lines of code? Please show us the first four or five lines of code. Otherwise it's hard to help you as we don't know what you do. :rolleyes:
------------------------------ Author of Primary ROleplaying SysTem How do I take my coffee? Black as midnight on a moonless night. War doesn't determine who's right. War determines who's left.
-
sindhuan wrote:
Can Some one please help me out
So there are errors for the first four lines of code? Please show us the first four or five lines of code. Otherwise it's hard to help you as we don't know what you do. :rolleyes:
------------------------------ Author of Primary ROleplaying SysTem How do I take my coffee? Black as midnight on a moonless night. War doesn't determine who's right. War determines who's left.
ya..I have given the code below /* Deployment script for Test2 */ GO SET ANSI_NULLS, ANSI_PADDING, ANSI_WARNINGS, ARITHABORT, CONCAT_NULL_YIELDS_NULL, QUOTED_IDENTIFIER ON; SET NUMERIC_ROUNDABORT OFF; GO :setvar DatabaseName "Test2" :setvar DefaultDataPath "C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\DATA\" :setvar DefaultLogPath "C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\DATA\" GO :on error exit GO USE [master] GO IF (DB_ID(N'$(DatabaseName)') IS NOT NULL AND DATABASEPROPERTYEX(N'$(DatabaseName)','Status') <> N'ONLINE') BEGIN RAISERROR(N'The state of the target database, %s, is not set to ONLINE. To deploy to this database, its state must be set to ONLINE.', 16, 127,N'$(DatabaseName)') WITH NOWAIT RETURN END GO IF NOT EXISTS (SELECT 1 FROM [master].[dbo].[sysdatabases] WHERE [name] = N'$(DatabaseName)') BEGIN RAISERROR(N'You cannot deploy this update script to target INP-X. The database for which this script was built,Test2, does not exist on this server.', 16, 127) WITH NOWAIT RETURN END GO
-
ya..I have given the code below /* Deployment script for Test2 */ GO SET ANSI_NULLS, ANSI_PADDING, ANSI_WARNINGS, ARITHABORT, CONCAT_NULL_YIELDS_NULL, QUOTED_IDENTIFIER ON; SET NUMERIC_ROUNDABORT OFF; GO :setvar DatabaseName "Test2" :setvar DefaultDataPath "C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\DATA\" :setvar DefaultLogPath "C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\DATA\" GO :on error exit GO USE [master] GO IF (DB_ID(N'$(DatabaseName)') IS NOT NULL AND DATABASEPROPERTYEX(N'$(DatabaseName)','Status') <> N'ONLINE') BEGIN RAISERROR(N'The state of the target database, %s, is not set to ONLINE. To deploy to this database, its state must be set to ONLINE.', 16, 127,N'$(DatabaseName)') WITH NOWAIT RETURN END GO IF NOT EXISTS (SELECT 1 FROM [master].[dbo].[sysdatabases] WHERE [name] = N'$(DatabaseName)') BEGIN RAISERROR(N'You cannot deploy this update script to target INP-X. The database for which this script was built,Test2, does not exist on this server.', 16, 127) WITH NOWAIT RETURN END GO
sindhuan wrote:
:setvar DatabaseName "Test2"
Well you are not in SQL-Commandmode, I bet. Change it in the MS Sql Server Management Studio. Go to Query->SQLCMD-Mode Better way to change (in my opinion):
SET @DatabaseName VARCHAR(32) = 'Test'
...
IF (DB_ID(N'$(@DatabaseName)') IS NOT NULL------------------------------ Author of Primary ROleplaying SysTem How do I take my coffee? Black as midnight on a moonless night. War doesn't determine who's right. War determines who's left.
-
Hi All, I have created two databases Test1 and Test2. For one database(Test1) I got the latest version of the code, created the deployement script and deployed the changes to the db.For the other database(Test2) I need to run the deployment script which got created form the Test1 DB.I tried to run the script but my db is not supporting..I get the following errors.. Msg 102, Level 15, State 1, Line 1 Incorrect syntax near ':'. Msg 102, Level 15, State 1, Line 1 Incorrect syntax near ':'. Msg 50000, Level 16, State 127, Line 4 You cannot deploy this update script to target INP-xx. The database for which this script was built, Test2, does not exist on this server. Msg 911, Level 16, State 1, Line 1 Database '$(DatabaseName)' does not exist. Make sure that the name is entered correctly. Can Some one please help me out
-
You need to run this script in SQLCMD mode. Goto the menu, click Query > SQLCMD Mode Now you will be able to run your script.
-
What am I supposed to do...go to Query->SQLCMD MODE then paste the script and click on execute??
sindhuan wrote:
What am I supposed to do...go to Query->SQLCMD MODE then paste the script and click on execute??
Well, give it a try! :-\
------------------------------ Author of Primary ROleplaying SysTem How do I take my coffee? Black as midnight on a moonless night. War doesn't determine who's right. War determines who's left.
-
What am I supposed to do...go to Query->SQLCMD MODE then paste the script and click on execute??
sindhuan wrote:
What am I supposed to do...go to Query->SQLCMD MODE then paste the script and click on execute??
You could ask Google what this "CMD MODE" is, what it does, and where it lives. Try to get to know the beast, as opposed to "try and see if it works".
Bastard Programmer from Hell :suss: if you can't read my code, try converting it here[^]
-
What am I supposed to do...go to Query->SQLCMD MODE then paste the script and click on execute??