0

I am attempting to create a batch file in windows that will take a user's input, and pass that along to a sql file containing the following query, so that I can set a siteid, like in the following sql query:

exec sp_addlinkedserver [sqlserver1]
select * from [sqlserver1].onesource.dbo.admsites where siteid = '123'

I want to then take the results of this query, particularly the admsiteid, and then use the results of the query, and insert that into the originatorid (using another .sql file:

Use Onesource
update OSCsettings set originatorid = 'whatever-the-admsiteid-is'

How would I go about passing along these variables?

4

1 Answer 1

1

sqlcmd with the -v command line

-v var = "value"

You can specify multiple variables in the list.

See:

http://msdn.microsoft.com/en-us/library/ms162773.aspx

and

http://msdn.microsoft.com/en-us/library/ms188714.aspx

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.