Showing posts with label suggest. Show all posts
Showing posts with label suggest. Show all posts

Wednesday, March 7, 2012

OSQL Ouput Formatting.

Hi,
When I execute a query in OSQL using Query Analyser the output is not well
formatted.
Sample Query is given below.
Can someone suggest me a way to get good readable format in QA.
Thanks in advance.
-Kumar.
--***--
SELECT TOP 3 * FROM pubs..authors
--Using Command Prompt:
--osql -E -Q "SELECT TOP 3 * FROM authors" -d pubs
--Using Query Analyser:
DECLARE @.vcSQLCmd VARCHAR(1000)
SET @.vcSQLCmd = 'osql -E -Q "SELECT * FROM authors" -d pubs'
EXEC master..xp_cmdShell @.vcSQLCmd
--***--
--SeequellWhy are you using osql, if you want the results in QA? Why not use it
directly?
Anith|||Let me give more details...
I have few script files and those need to be run against few Db Servers/DBs.
I would like to run these scripts from my computer by just changing
Server/Db name.
--Seequell
"Anith Sen" wrote:

> Why are you using osql, if you want the results in QA? Why not use it
> directly?
> --
> Anith
>
>|||>> I have few script files and those need to be run against few Db
OK, with osql there results are formatted to display at the command prompt.
And there is not much you can do to change it in Query Analyzer.
In you case, if QA formatting is important consider using 4 part naming (
server.database.owner.object ) or a pass-though query ( like OPENQUERY,
OPENROWSET etc. ) to access data from external servers. Details about linked
servers ( 4 part naming ) as well as using distributed queries are well
documented in SQL Server Books Online.
Anith|||Thanks a lot Anith.
--Seequell
"Anith Sen" wrote:

> OK, with osql there results are formatted to display at the command prompt
.
> And there is not much you can do to change it in Query Analyzer.
> In you case, if QA formatting is important consider using 4 part naming (
> server.database.owner.object ) or a pass-though query ( like OPENQUERY,
> OPENROWSET etc. ) to access data from external servers. Details about link
ed
> servers ( 4 part naming ) as well as using distributed queries are well
> documented in SQL Server Books Online.
> --
> Anith
>
>|||Hi Anith,
I found a -w switch in OSQL for changing the width of the output, I think.
I am exploring more on it. Thanks.
--Seequell
"Seequell" wrote:
> Thanks a lot Anith.
> --Seequell
>
> "Anith Sen" wrote:
>

osql -L

Can anyone suggest why two client PCs on the same network report different
lists of servers using osql -L ?
Nick.
BOL says the -L option 'Lists the locally configured servers and the names
of the servers broadcasting on the network.'
So... it could be that they really are on different subnets and yuo don't
realize it. But 'locally configured' servers is the more likely answer.
-L will show all server aliases hat are defined on the client using the
Client Network Utility. You probably have different lists there...
Brian Moran
Principal Mentor
Solid Quality Learning
SQL Server MVP
http://www.solidqualitylearning.com
"Nick Stephens" <NickStephens@.discussions.microsoft.com> wrote in message
news:7C1AC5D3-F374-4BFA-B220-90D97DD253F4@.microsoft.com...
> Can anyone suggest why two client PCs on the same network report different
> lists of servers using osql -L ?
> Nick.
|||My colleague and I had also discussed the possibility of different subnets
being an issue, but didn't have the tehcnical knowledge to sound out our
ideas so we moved on and in fact checked out the configs via the Client
Network Utility.
The only difference that we found was a single alias on his machine whereas
on mine the list is empty and yet there are 49 servers to be found. Maybe
there's a different list of which I'm unaware ?
Inspired by a reply to a similar post I knocked up a quick VB6 app to use
DMO and list the servers. Unsurprisingly, I got exactly the same list as with
osql -L.
However, several entries in my list differ from that when we use my
colleague's machine.
Still, at your suggestion I'll take a closer look at the configs, Biran -
many thanks for your help.
Regards, Nick.
"Brian Moran" wrote:

>
> BOL says the -L option 'Lists the locally configured servers and the names
> of the servers broadcasting on the network.'
> So... it could be that they really are on different subnets and yuo don't
> realize it. But 'locally configured' servers is the more likely answer.
> -L will show all server aliases hat are defined on the client using the
> Client Network Utility. You probably have different lists there...
> --
> Brian Moran
> Principal Mentor
> Solid Quality Learning
> SQL Server MVP
> http://www.solidqualitylearning.com
>
> "Nick Stephens" <NickStephens@.discussions.microsoft.com> wrote in message
> news:7C1AC5D3-F374-4BFA-B220-90D97DD253F4@.microsoft.com...
>
>
|||Brian, further to my initial reply to your post, we have found that it is
indeed a subnet thang. Our machines are on different subnets.
Thanks again.
Regards, Nick.
"Brian Moran" wrote:

>
> BOL says the -L option 'Lists the locally configured servers and the names
> of the servers broadcasting on the network.'
> So... it could be that they really are on different subnets and yuo don't
> realize it. But 'locally configured' servers is the more likely answer.
> -L will show all server aliases hat are defined on the client using the
> Client Network Utility. You probably have different lists there...
> --
> Brian Moran
> Principal Mentor
> Solid Quality Learning
> SQL Server MVP
> http://www.solidqualitylearning.com
>
> "Nick Stephens" <NickStephens@.discussions.microsoft.com> wrote in message
> news:7C1AC5D3-F374-4BFA-B220-90D97DD253F4@.microsoft.com...
>
>
|||You can get different results at different times from the same PC as
well due to server responses not coming back in time. OSQL -L is based
on UDP network broadcasts. There are different factors that play into
what you get back for results. You can find the issues listed at:
http://www.sqldev.net/misc/ListSQLSvr.htm
-Sue
On Thu, 4 Nov 2004 08:13:03 -0800, "Nick Stephens"
<NickStephens@.discussions.microsoft.com> wrote:
[vbcol=seagreen]
>Brian, further to my initial reply to your post, we have found that it is
>indeed a subnet thang. Our machines are on different subnets.
>Thanks again.
>Regards, Nick.
>"Brian Moran" wrote:
|||Many thanks, Sue !
Nick.
"Sue Hoegemeier" wrote:

> You can get different results at different times from the same PC as
> well due to server responses not coming back in time. OSQL -L is based
> on UDP network broadcasts. There are different factors that play into
> what you get back for results. You can find the issues listed at:
> http://www.sqldev.net/misc/ListSQLSvr.htm
> -Sue
> On Thu, 4 Nov 2004 08:13:03 -0800, "Nick Stephens"
> <NickStephens@.discussions.microsoft.com> wrote:
>
>