Search found 3 matches

by jpohl
01 Dec 2011 19:03
Forum: DOS Batch Forum
Topic: Setting a variable from the output of a command (sqlcmd)
Replies: 5
Views: 17923

Re: Setting a variable from the output of a command (sqlcmd)

I got it working by outputing to a file and then reading it. There is probably a way to direct it straight to a variable, but I've spent too much time on it already. Here is what I've done: SET OBJECT_VER_DB=NULL ::Write the Object Version to a temporary file IF %~1 EQU tables (sqlcmd -S %DBSERVER%\...
by jpohl
01 Dec 2011 18:24
Forum: DOS Batch Forum
Topic: Setting a variable from the output of a command (sqlcmd)
Replies: 5
Views: 17923

Re: Setting a variable from the output of a command (sqlcmd)

I attempted this code. And it did not work. I changed the DO part of the FOR loop to be:
do SET OBJECT_VER_DB=%%?_

and then I did a echo %OBJECT_VER_DB%, but the variable did not change at all.
by jpohl
30 Nov 2011 19:41
Forum: DOS Batch Forum
Topic: Setting a variable from the output of a command (sqlcmd)
Replies: 5
Views: 17923

Setting a variable from the output of a command (sqlcmd)

I am attempting to do something releatively simple, but am having great difficulty. I want to sent a variable (%OBJECT_VER_DB%) from the output of a command. The command happens to be the output of a query from SQL server. If I run the following command, it returns a string: sqlcmd -S %DBSERVER%\%DB...