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 2005 Forums
 Transact-SQL (2005)
 sqlcmd question

Author  Topic 

Abu-Dina
Posting Yak Master

206 Posts

Posted - 2008-03-03 : 10:16:12
Greetings all!

i am using the follownig sqlcmd command to output some data :

sqlcmd -E -S myServer\myInstance -s "," -W -d myDB -Q " set nocount on select ltrim('""' + cast(PersonId as varchar) + 
'-' + cast(DatabaseId as varchar) + '""') as 'URN-DBID','""' + EmailAddress + '""' as EmailAddress from myDB.dbo.myTable where
DTS > dateadd(dd, -7, getdate()) set nocount off " > "\\tfsvr\Company\Database Development\TestReports\"myRecords-20080303.txt


The output looks something like this :

URN-DBID,EmailAddress
--------,------------
"5-1","blahblah@HOTMAIL.COM"
"264541-1","blahblah@HOTMAIL.COM"
"1107457-1","blahblah@HOTMAIL.COM"
"6133752-1","blahblah@HOTMAIL.COM"


Is it possible to keep the headnigs but remove the dashed line?

Your help would be much appreciated.

rmiao
Master Smack Fu Yak Hacker

7266 Posts

Posted - 2008-03-03 : 23:23:36
Tried with bcp instead?
Go to Top of Page

Abu-Dina
Posting Yak Master

206 Posts

Posted - 2008-03-04 : 07:05:48
quote:
Originally posted by rmiao

Tried with bcp instead?



That's what I am trying now as suggested by someone on the MSDN forums. But I can't get it to work. I get an error (Unknown Argument).. Seems like it doesn't like my Server name or something.

Can anybody suggest to me what the problem with the follownig is?

bcp "select * from ##Extract order by URN desc" queryout
\\someNWdrive\Shared\blahblahblah\ExtractProcessing\Completed\Extractt_TTF_2008-224rr4.txt -c -t, -T -S DEREK\PREPRODUCTION



Go to Top of Page

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2008-03-04 : 07:15:45
You can't access global temp table from BCP.

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

Abu-Dina
Posting Yak Master

206 Posts

Posted - 2008-03-04 : 07:21:06
quote:
Originally posted by harsh_athalye

You can't access global temp table from BCP.

Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"



That's not true.

Anyway, I got the same error even when I tried to output the data held in a permanent table.
Go to Top of Page

Abu-Dina
Posting Yak Master

206 Posts

Posted - 2008-03-04 : 07:56:48
I solved it!

I put double quotes around my entire path and it worked!

Sorry for the bother.
Go to Top of Page
   

- Advertisement -