Search code examples
sql-server-2008sql-server-2008-r2

how to run .sql file from SSMS?


Hi i am using SQL SERVER 2008 R2 and i wanted to execute prestored *.sql files in a folder and wanted to run in SSMS. can it be possible and if possible can somebody please help me to get how can we implement that?


Solution

  • Ok If I'm clear with your question.

    1. Go to cmd and navigate to the path where you have stored your .sql file.
    2. In my case I've stored file on desktop with vish.sql name.
    3. then sqlcmd -S DALVI1 -d cookbookdb -i vish.sql

    Note (This is my configuration DALVI1 is my ServerName cookbookdb is database name vish.sql is filename)

    Modify as per your configuration. For More Reference

    enter image description here