July 4, 2005 at 5:32 am
osql -Usa -Pbinujohn -dmaster -Q"sp_msforeachdb @command1="print '?'""
Is not giving any results.anybody have any idea??
July 4, 2005 at 5:42 am
Try osql -SServerNameHere -E -dmaster -Q"sp_msforeachdb @command1='print "?"'"
Good Hunting!
AJ Ahrens
webmaster@kritter.net
July 4, 2005 at 6:03 am
Getting the samething!!
C:\>osql -SWIP-7ADLZFDZW -E -dmaster -Q"sp_msforeachdb @command1="print '?'""
usage: osql [-U login id] [-P password]
[-S server] [-H hostname] [-E trusted connection]
[-d use database name] [-l login timeout] [-t query timeout]
[-h headers] [-s colseparator] [-w columnwidth]
[-a packetsize] [-e echo input] [-I Enable Quoted Identifiers]
[-L list servers] [-c cmdend] [-D ODBC DSN name]
[-q "cmdline query"] [-Q "cmdline query" and exit]
[-n remove numbering] [-m errorlevel]
[-r msgs to stderr] [-V severitylevel]
[-i inputfile] [-o outputfile]
[-p print statistics] [-b On error batch abort]
[-O use Old ISQL behavior disables the following]
batch processing
Auto console width scaling
Wide messages
default errorlevel is -1 vs 1
[-? show syntax summary]
Before I was trying on local instance.
July 4, 2005 at 6:03 am
Getting the samething!!
C:\>osql -SWIP-7ADLZFDZW -E -dmaster -Q"sp_msforeachdb @command1="print '?'""
usage: osql [-U login id] [-P password]
[-S server] [-H hostname] [-E trusted connection]
[-d use database name] [-l login timeout] [-t query timeout]
[-h headers] [-s colseparator] [-w columnwidth]
[-a packetsize] [-e echo input] [-I Enable Quoted Identifiers]
[-L list servers] [-c cmdend] [-D ODBC DSN name]
[-q "cmdline query"] [-Q "cmdline query" and exit]
[-n remove numbering] [-m errorlevel]
[-r msgs to stderr] [-V severitylevel]
[-i inputfile] [-o outputfile]
[-p print statistics] [-b On error batch abort]
[-O use Old ISQL behavior disables the following]
batch processing
Auto console width scaling
Wide messages
default errorlevel is -1 vs 1
[-? show syntax summary]
Before I was trying on local instance.
July 4, 2005 at 1:53 pm
Did you try copying my code and changing the servername?
Good Hunting!
AJ Ahrens
webmaster@kritter.net
July 4, 2005 at 11:58 pm
Try osql -SServerNameHere -E -dmaster -Q"sp_msforeachdb @command1='print "?"'"
C:\>osql -SWIP-7ADLZFDZW -E -dmaster -Q"sp_msforeachdb @command1="print '?'""
I tried your code only.WIP-7ADLZFDZW is the server name.
Regards
Binu John
July 5, 2005 at 12:33 am
The correct syntax is:
osql -SWIP-7ADLZFDZW -E -dmaster -Q"sp_msforeachdb @command1='print ?'"
Double quotes around the SQL command line query and single quotes around the @command input.
Regards
hot2use
__________________________________
Searching the KB articles is like
picking your nose. You never know
what you'll find.
July 5, 2005 at 1:01 am
Tried this osql -SWIP-7ADLZFDZW -E -dmaster -Q"sp_msforeachdb @command1='print ?'"
But giving error like this for all databases.
Server: Msg 128, Level 15, State 1, Line 1
The name 'DBA' is not permitted in this context. Only constants, expressions, or variables allowed here. Column names are not permitted.
But if you execute
sp_msforeachdb @command1="print '?' "
in QAthis will give correct result.
Any Idea??
July 5, 2005 at 2:42 am
The solution is extra double quotes to quote the quotes:
... -Q"sp_msforeachdb @command1="""print '?'""""
Thats single quotes around the question mark, 3 double quotes before the print command and 4 (yes four!) double quotes at the end.
July 5, 2005 at 2:48 am
Great Rutter, and thanks.
Its working now.
Regards
Binu John
Viewing 10 posts - 1 through 9 (of 9 total)
You must be logged in to reply to this topic. Login to reply