September 13, 2004 at 1:10 am
Hi,
i am using command files(.cmd) and osql utility to conneft to a database.
following is the requirement.
I have a query "SELECT top 1 au_fname FROM pubs..authors".
Can i store the value of au_fname in the command file?
Is there any work around for this.
Any help is appreciated.
Thanks..
September 13, 2004 at 6:36 am
You could generate your queries as you desire and store them in a file and then use osql to execute from the saved file(s).
Johan
Learn to play, play to learn !
Dont drive faster than your guardian angel can fly ...
but keeping both feet on the ground wont get you anywhere :w00t:
- How to post Performance Problems
- How to post data/code to get the best help[/url]
- How to prevent a sore throat after hours of presenting ppt
press F1 for solution, press shift+F1 for urgent solution 😀
Need a bit of Powershell? How about this
Who am I ? Sometimes this is me but most of the time this is me
September 13, 2004 at 7:20 am
I'm assuming he knows how to pose the query using osql, but doesn't know how to get the result of the query into an environment variable for use in an ECHO or some such thing. One way of doing this is to write the osql results to an output file and configure your output to be the desired CMD script that you can then CALL= from your primary CMD script. For example:
YourCmd.cmd =
osql -U username -P password -S SrvName -d dbName -n -i input.sql -o report.cmd call=report.cmd ECHO it returned %AU_FNAME% |
input.sql =
set nocount on declare @au_fname varchar(100) SELECT top 1 @au_fname = au_fname FROM pubs..authors print '@ECHO OFF SET AU_FNAME=' + @au_fname + ' ECHO AU_FNAME assigned to "' + @au_fname + '"' |
September 14, 2004 at 4:27 am
Hey Hippy!!
this worked..thanks a lot for your help..
Cheers!!
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply