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 |
|
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 workshas 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 |
 |
|
|
tuenty
Constraint Violating Yak Guru
278 Posts |
Posted - 2004-09-30 : 17:26:46
|
| [code]Declare @num as numeric --number to be convertedDeclare @len as tinyint --length of the resulting stringSet @num = 1set @len = 2print replace(str(@num,@len),' ','0')[/code]*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*A candle loses nothing by lighting another candle |
 |
|
|
|
|
|