Stan
Stan

Reputation: 38255

How to execute .sql file in SQL server 2000/2005/2008

When get a .sql file, how do you execute it? Double click to open it and press F5? Is there any other way to execute it and also able to see the execution result. Thanks.

Upvotes: 0

Views: 3118

Answers (1)

Preet Sangha
Preet Sangha

Reputation: 65476

run the OSQL or SqlCmd tools

for example

osql -D db_name -S server_name -U username -P password -i sqlfile
or
sqlcmd -D db_name -S server_name -U username -P password -i sqlfile

or you can use -E instead of user and password to do integrated security

Upvotes: 3

Related Questions