Home All Groups Group Topic Archive Search About
Author
16 Sep 2005 5:10 PM
Seequell
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
---***---


--Seequell

Author
16 Sep 2005 5:25 PM
Anith Sen
Why are you using osql, if you want the results in QA? Why not use it
directly?

--
Anith
Author
16 Sep 2005 6:00 PM
Seequell
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


Show quote
"Anith Sen" wrote:

> Why are you using osql, if you want the results in QA? Why not use it
> directly?
>
> --
> Anith
>
>
>
Author
16 Sep 2005 6:16 PM
Anith Sen
>> 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.

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
Author
16 Sep 2005 6:40 PM
Seequell
Thanks a lot Anith.

--Seequell


Show quote
"Anith Sen" wrote:

> >> 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.
>
> 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
>
>
>
Author
19 Sep 2005 1:47 PM
Seequell
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


Show quote
"Seequell" wrote:

> Thanks a lot Anith.

> --Seequell
>
>
> "Anith Sen" wrote:
>
> > >> 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.
> >
> > 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
> >
> >
> >

AddThis Social Bookmark Button