Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Import/Export (DTS) and Replication (2000)
 export query to notepad

Author  Topic 

oracle_corrgi
Yak Posting Veteran

98 Posts

Posted - 2007-01-08 : 07:43:55
hi
i need to run a big query say 50line query which gives me 5 output

2943 Records, Jan 5 2007 1:23AM
197 Records, Feb 28 2006 1:00PM
No Data

No Data
1 Records, Jan 6 2007 8:01PM

i need to export the query out to a c:\data\test.txt file
is it possible to
use dcp,isql,osql
C:\>bcp "SELECT GETDATE()" queryout testfinal.txt -c -t ","
-Uxyz -Pabc -Sserverab

C:\>isql -Sserverab -Uxyz -Pabc -d northwind -q"select getdate()" -o.\erappa.txt

how can i do this i dont want to use DTS or query analyzer
i need to this by command prompt(windows)
thanxs


coorgi

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2007-01-08 : 08:47:59
So what's the problem? Is it working the way you posted here.

Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page

oracle_corrgi
Yak Posting Veteran

98 Posts

Posted - 2007-01-08 : 22:03:28
its not working i cannot run a bigger query using this option isql ,osql ,bcp

coorgi
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2007-01-08 : 22:25:47
convert your query into a stored procedure and execute it via bcp


KH

Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2007-01-08 : 22:29:07
"i cannot run a bigger query using this option ... osql"

I've run massive SQL Scripts via OSQL without any limitations that I can think of.

But khtan's answer is probably the best.

Kristen
Go to Top of Page

oracle_corrgi
Yak Posting Veteran

98 Posts

Posted - 2007-01-09 : 02:03:03
hi
i have limitation on this
iam working or monitoring on remote production database i cannot create sp on the database and i dont want to do that can run this query without creating any object .i want to run from local command prompt by given the reqiured info
c:>isqlw -S BOSPRODOL401\C -d MBI401 -U abc -P axxy -i C:\Public\macros_test\ZBA_Agent.sql -o C:\Public\macros_test\editest.txt

the sample query is ...........
select getdate() as "Query Time"
select count(*) as "ZBA Agent" from dbo.vw_email_complete_queue(nolock) where insert_dte > '01/01/2005'
and email_type_cde in (4,5)

select getdate() as "Missing Transactions"
SELECT daily_proc_status_cde,*
FROM setl_day_totals
WHERE setl_dte =dbo.udf_FormatShortDate(GETDATE())

can i use bcp , isql ,osql and others
after this i need to shedule this through

coorgi
Go to Top of Page

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2007-01-09 : 02:36:47
What is the error you are getting? Are you running query on proper database?

Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page

oracle_corrgi
Yak Posting Veteran

98 Posts

Posted - 2007-01-09 : 02:48:47
i am not getting any error
EDI QUERY TIME
------------------------------------------------------
2007-01-08 21:33:26.077

(1 row(s) affected)

EDI Query #1
------------
No Data

(1 row(s) affected)

EDI Query #2
------------
No Data

(1 row(s) affected)

0
Nigtly Process
--------------
No Data

(1 row(s) affected)

i need to get only the query out put

7620 Records, Jan 1 2007 1:18AM
No data
620 Records, Jan 1 2007 1:18AM

No data
1 Records, Jan 1 2007 1:13AM

is it possible to run .sql and get the query out put
coorgi
Go to Top of Page

oracle_corrgi
Yak Posting Veteran

98 Posts

Posted - 2007-01-09 : 05:03:50
is there any one

coorgi
Go to Top of Page

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2007-01-10 : 01:07:45
You will have to make efforts to format data the way you want. To remove column headings, use -h-1 option in OSQL. To remove (1 row(s) affected) message, you will need to add SET NOCOUNT ON to your script file.

Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page

oracle_corrgi
Yak Posting Veteran

98 Posts

Posted - 2007-01-11 : 02:39:32
hi
thanxs i need some modifycation
at all the work i finally got the data like this
Auto Deposit Query #1
---------------------
1986 Records, Jan 10 2007 1:27AM

Auto Deposit Query #2
---------------------
No Data

Auto Deposit Query #3
---------------------
60 Records, Dec 20 2004 9:39AM

EDI Query #1
------------
No Data

EDI Query #2
------------
1 Records, Jan 11 2007 12:02AM


tpa_id
file_name


edi_req_status_cde
edi_proc_status_cde edi_req_key proc_start_dte
proc_end_dte req_dte
------
-----------------------------------------------------------------------
-----------------------------------------------------------------------
-----------------------------------------------------------------------
------------------------------------------ ------------------
------------------- -------------------- --------------------
-------------------- --------------------

i need to get data like this

1986 Records, Jan 10 2007 1:27AM
No Data
60 Records, Dec 20 2004 9:39AM

No Data
1 Records, Jan 11 2007 12:02AM

i dont need extra data why is this ???
thanxs



coorgi
Go to Top of Page

oracle_corrgi
Yak Posting Veteran

98 Posts

Posted - 2007-01-11 : 03:56:57
is any one there

coorgi
Go to Top of Page
   

- Advertisement -