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
 General SQL Server Forums
 New to SQL Server Programming
 exporting data

Author  Topic 

Peet
Starting Member

3 Posts

Posted - 2007-07-05 : 12:11:02
Guys,

I'm trying to export data from SQL. Can anyone help. I have commented my script below and have managed to create a table, insert using 'bulk insert' - now I want to export the data out. I'm getting an error message saying 'cannot use the output option when passing to a stored procedure'.

comment
-----------
drop table for re-runs !
-----------

drop table JET
go

comment
------------
create a table to match the .txt file importing
----------

create table JET
( [USER] char( 25),
[DESC] char (20),
SYSDATE datetime,
SYSVALUE MONEY ,
POSTDATE datetime,
POSTVALUE MONEY,
GLCODE CHAR (20)
)

comment
---------------
import using pipe delimited .txt file
--------------

bulk insert JET from 'D:\Documents and Settings\mpeet\SQL Test.txt'
with
(
fieldterminator = '|',
firstrow = 2
)

comment
-------
check results
-------

select *
from JET


NEW BATCH

bcp JET out 'D:\Documents and Settings\mpeet\SQL Testexport.txt'

I want extract the data to a .txt file would anyone know the syntax?

Cheers

Michael

rmiao
Master Smack Fu Yak Hacker

7266 Posts

Posted - 2007-07-05 : 12:29:00
Need specify server name, db name and login info in bcp. Check syntax with 'bcp /?'.
Go to Top of Page

Peet
Starting Member

3 Posts

Posted - 2007-07-06 : 06:06:20
I have used the following syntax stated in SQL help.

bcp
"master mpeet jet" out 'd:/Peet.xls' -c -q -s"UK52785\LOCAL"

I get the following error message: 'Cannot use the OUTPUT option when passing a constant to a stored prcoedure'

Any ideas?

Cheers

Michael
Go to Top of Page

rmiao
Master Smack Fu Yak Hacker

7266 Posts

Posted - 2007-07-06 : 10:46:14
Which db the table jet is in? Should be db_name.owner.jet instead of 'master mpeet jet'.
Go to Top of Page
   

- Advertisement -