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
 Transact-SQL (2000)
 Adding double quotes to resultset

Author  Topic 

mn757
Starting Member

15 Posts

Posted - 2009-03-18 : 08:10:11
Hi all,

I have a view, the contents of which are exported to a csv file using BCP. I now need to amend the csv file to include double quotes around each value, as well as the comma delimiter (which I already have). I am struggling to find a way to do this. Can anyone help.

I have tried something along the lines of ;

SELECT TOP 100 PERCENT
dbo.Consultees.Consultee = ' " ' + dbo.Consultees.Consultee + ' " ',
FROM dbo.Planning_Applications............

but i'm going nowhere fast. fairly new to sql so any help greatly appreciated.

many thanks

mn757

bklr
Master Smack Fu Yak Hacker

1693 Posts

Posted - 2009-03-18 : 08:20:21
u want this
declare @t table(names varchar(12), value int)
insert into @t select 'defde', '1'
insert into @t select 'abc', '2'

select '"'+ names +'",' from @t
Go to Top of Page

mn757
Starting Member

15 Posts

Posted - 2009-03-18 : 08:37:19
Many thanks for your help, much appreciated
Go to Top of Page

Transact Charlie
Master Smack Fu Yak Hacker

3451 Posts

Posted - 2009-03-18 : 08:38:04
yes you can do it that way but you don't need to

You can use a custom format file for mcp. I've posted on a very similar thread recently. Have a look at : http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=121924


Charlie
===============================================================
Msg 3903, Level 16, State 1, Line 1736
The ROLLBACK TRANSACTION request has no corresponding BEGIN TRANSACTION
Go to Top of Page

bklr
Master Smack Fu Yak Hacker

1693 Posts

Posted - 2009-03-18 : 08:40:31
quote:
Originally posted by mn757

Many thanks for your help, much appreciated



welcome
Go to Top of Page
   

- Advertisement -