Reputation: 577
I have been following this tutorial: http://www.misfitgeek.com/2010/07/adding-asp-net-membership-to-your-own-database/
I have installed SQL Server Management Studio Express from here: http://www.microsoft.com/download/en/details.aspx?id=8961.
1) How can I locate my database?
2) How do I run the SQL script on my database from external file?
Upvotes: 51
Views: 393250
Reputation: 1
You can also use the SQLCMD option in Management Studio.
With a blank SQL window, go to Query menu, select SQLCMD Mode, and run your script using the following syntax:
set nocount on
:r <path to your file>
Upvotes: 0
Reputation: 41
Found this in another thread that helped me: Use xp_cmdshell and sqlcmd Is it possible to execute a text file from SQL query? - by Gulzar Nazim
EXEC xp_cmdshell 'sqlcmd -S ' + @DBServerName + ' -d ' + @DBName + ' -i ' + @FilePathName
Upvotes: 4
Reputation: 1071
Open SQL Server Management Studio > File > Open > File > Choose your .sql file (the one that contains your script) > Press Open > the file will be opened within SQL Server Management Studio, Now all what you need to do is to press Execute button.
Upvotes: 29
Reputation: 13419
This website has a concise tutorial on how to use SQL Server Management Studio. As you will see you can open a "Query Window", paste your script and run it. It does not allow you to execute scripts by using the file path. However, you can do this easily by using the command line (cmd.exe):
sqlcmd -S .\SQLExpress -i SqlScript.sql
Where SqlScript.sql
is the script file name located at the current directory. See this Microsoft page for more examples
Upvotes: 82