Executing .sql scripts file from command prompt

  • I had created the .sql scripts for

    --Create Database

    --Create tables

    --Create Stored procedure

    I am using SQL server 2008.

    Now i want to deploy it into the target server using the command prompt.

    How can I call to execute that script on the target server?

  • exec master.dbo.xp_cmdshell 'osql -E -Sserver1 -i c:\temp\<filename>.sql'

    Make sure the following too:

    EXEC sp_configure 'xp_cmdshell', 1

    RECONFIGURE

    GO

  • I wanna create a .cmd file and have to make it simple so non technical person can do it from command line using the installation instructions.

  • Its a command line execution method only.

    Create a batch file.

    Place the statements correctly with correct server name.

    Place Go in between the commands.

    If am not answering your question, write in again.

  • Hi,

    I created the .bat file but i need something like ...

    If any one click on the batch file ,then i want that it ask for the server name and then that perticular scripts run on that server.

    I don't wanna use the server name in the .bat file.

    I will appriciate your help.

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply