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
 SQL Server Development (2000)
 csv file and data format

Author  Topic 

partha
Starting Member

4 Posts

Posted - 2004-09-30 : 14:49:52
if i have the data type as NVARCHAR in the table and value for the field = '01'and the value returned in .csv file = 1, i want the data to be '01' and not '1'

i have tried CAST and nothing works

has anyone know about it?

Yes i am using bcp to output to .csv file through stored procedure

mwjdavidson
Aged Yak Warrior

735 Posts

Posted - 2004-09-30 : 16:29:39
You may be able to use REPLICATE in conjunction with LEN to add the required number of leading zeros. It sounds as if you are exporting data. Is this the case? If so, by what method?

Mark
Go to Top of Page

tuenty
Constraint Violating Yak Guru

278 Posts

Posted - 2004-09-30 : 17:26:46
[code]Declare @num as numeric --number to be converted
Declare @len as tinyint --length of the resulting string

Set @num = 1
set @len = 2

print replace(str(@num,@len),' ','0')[/code]
*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*

A candle loses nothing by lighting another candle
Go to Top of Page
   

- Advertisement -