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.
Author |
Topic |
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2002-08-12 : 08:26:35
|
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" |
|
|
|
|