Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

sql version query in a batch file

Status
Not open for further replies.

37grove

MIS
Jun 29, 2002
65
0
0
US
Hello,

Can anyone tell me how to put the following sql query command in a batch file so that it would be displayed in the in dos window.

SELECT SERVERPROPERTY('productversion'), SERVERPROPERTY
('productlevel'), SERVERPROPERTY ('edition')

Thanks,
 
You would need to call sqlcmd or osql and give it that query as part of the command line arguments. Run either command with a /? after it from a command line to get the avaialble switches.

Denny
MCSA (2003) / MCDBA (SQL 2000)
MCTS (SQL 2005 / Microsoft Windows SharePoint Services 3.0: Configuration / Microsoft Office SharePoint Server 2007: Configuration)
MCITP Database Administrator (SQL 2005) / Database Developer (SQL 2005)

--Anything is possible. All it takes is a little research. (Me)
[noevil]
 
Denny,

this is how i have the batch file but i'm getting unexpected arguemnt error.

SQLCMD -q -e -E SELECT SERVERPROPERTY('productversion'), SERVERPROPERTY
('productlevel'), SERVERPROPERTY ('edition')

Can you give me some pointer on how to get it to work?

Thanks again,
 
Close. Try using this.
Code:
SQLCMD -q -e -E -Q "SELECT SERVERPROPERTY('productversion'), SERVERPROPERTY 
('productlevel'), SERVERPROPERTY ('edition')"

Denny
MCSA (2003) / MCDBA (SQL 2000)
MCTS (SQL 2005 / Microsoft Windows SharePoint Services 3.0: Configuration / Microsoft Office SharePoint Server 2007: Configuration)
MCITP Database Administrator (SQL 2005) / Database Developer (SQL 2005)

--Anything is possible. All it takes is a little research. (Me)
[noevil]
 
Denny,

I copied your code and but it in a batch file when i executed the batch from CMD i now get an error about missing argument.

This is what it's saying: sqlcmd: '-q': Misssing argument.

What else can i be missing?
 
Sorry, I didn't see the -q in there.
Code:
SQLCMD -e -E -Q "SELECT SERVERPROPERTY('productversion'), SERVERPROPERTY 
('productlevel'), SERVERPROPERTY ('edition')"
I've superseded -q with -Q.

Denny
MCSA (2003) / MCDBA (SQL 2000)
MCTS (SQL 2005 / Microsoft Windows SharePoint Services 3.0: Configuration / Microsoft Office SharePoint Server 2007: Configuration)
MCITP Database Administrator (SQL 2005) / Database Developer (SQL 2005)

--Anything is possible. All it takes is a little research. (Me)
[noevil]
 
No problem.

Denny
MCSA (2003) / MCDBA (SQL 2000)
MCTS (SQL 2005 / Microsoft Windows SharePoint Services 3.0: Configuration / Microsoft Office SharePoint Server 2007: Configuration)
MCITP Database Administrator (SQL 2005) / Database Developer (SQL 2005)

--Anything is possible. All it takes is a little research. (Me)
[noevil]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top