Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. sql script

sql script

Scheduled Pinned Locked Moved Database
databasesysadminannouncementtoolshelp
9 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    sindhuan
    wrote on last edited by
    #1

    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

    I J 2 Replies Last reply
    0
    • S sindhuan

      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

      I Offline
      I Offline
      Ingo
      wrote on last edited by
      #2

      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.

      S 1 Reply Last reply
      0
      • I Ingo

        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.

        S Offline
        S Offline
        sindhuan
        wrote on last edited by
        #3

        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

        I 1 Reply Last reply
        0
        • S sindhuan

          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

          I Offline
          I Offline
          Ingo
          wrote on last edited by
          #4

          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.

          1 Reply Last reply
          0
          • S sindhuan

            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

            J Offline
            J Offline
            J4amieC
            wrote on last edited by
            #5

            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.

            S 1 Reply Last reply
            0
            • J J4amieC

              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.

              S Offline
              S Offline
              sindhuan
              wrote on last edited by
              #6

              What am I supposed to do...go to Query->SQLCMD MODE then paste the script and click on execute??

              I L J 3 Replies Last reply
              0
              • S sindhuan

                What am I supposed to do...go to Query->SQLCMD MODE then paste the script and click on execute??

                I Offline
                I Offline
                Ingo
                wrote on last edited by
                #7

                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.

                1 Reply Last reply
                0
                • S sindhuan

                  What am I supposed to do...go to Query->SQLCMD MODE then paste the script and click on execute??

                  L Offline
                  L Offline
                  Lost User
                  wrote on last edited by
                  #8

                  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[^]

                  1 Reply Last reply
                  0
                  • S sindhuan

                    What am I supposed to do...go to Query->SQLCMD MODE then paste the script and click on execute??

                    J Offline
                    J Offline
                    J4amieC
                    wrote on last edited by
                    #9

                    You don't need to copy/paste. Just open the script in SSMS, then click Query>CMD Mode, then click run.

                    1 Reply Last reply
                    0
                    Reply
                    • Reply as topic
                    Log in to reply
                    • Oldest to Newest
                    • Newest to Oldest
                    • Most Votes


                    • Login

                    • Don't have an account? Register

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • World
                    • Users
                    • Groups