SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2000 Forums
 Import/Export (DTS) and Replication (2000)
 Import Export in sqlserver2000 and CSV format
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

AskSQLTeam
Ask SQLTeam Question

USA
0 Posts

Posted - 08/12/2002 :  08:26:35  Show Profile  Visit AskSQLTeam's Homepage  Reply with Quote
Shweta writes "Hi,

I have an SP that creates a csv file from sqlserver 2000.
It works well but if a field value has comma then also it makes it as a column.
Is there any way so that I can get CSV file with columns enclosed in double quotes.

Here is the SP.

-- This Sql will Transfer SQL Server Table to .CSV

DECLARE @PATH VARCHAR(30)
DECLARE @DB VARCHAR(30)
DECLARE @TBl VARCHAR(30)
DECLARE @CMD VARCHAR(500)
DECLARE @QRY VARCHAR(500)

SET @PATH = 'C:\dts\'
set @TBl = 'authors'
set @DB = 'HRISTEST'

-- in transfer excel to Sql, Out transfers sql to Excel

SELECT @CMD = 'bcp ' + @DB + '..' + @TBl + ' out ' + @PATH + --@DB
+'_'+
@TBl +'.CSV' + ' -c -t \t -r \n '--/F 2'

SELECT @CMD

EXECUTE master..xp_cmdshell @cmd"
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.05 seconds. Powered By: Snitz Forums 2000