Groups | Blog | Home
all groups > sql server misc > february 2004 >

sql server misc : Formating a field in a view



Hallgeir
2/2/2004 8:54:45 PM
I have a SQLServer2000 database in which I have created a view. I want
to convert numeric values in a colum to string values, straight forward.
Example: the number 25 I want to convert to the string 25, number 7 I want
to convert to the string 7 and so on, and most import I want to convert 0 to
an empty space. I hope you be people are able to understand what I mean. I
guess my english could be better.

Thanks very much for your help.
Regards
Hallgeir


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.567 / Virus Database: 358 - Release Date: 24.01.2004

mountain man
2/3/2004 10:44:16 AM
[quoted text, click to view]


If the column is column_name then you should
check the CAST statement in the online doco.
try:

cast(column_name as varchar)

Cannot immediately recall how zero's are handled
but if you have problems then include a case
statement to the effect:

case when column_name = 0 then ' ' else cast(column_name as varchar) end



Good luck,




Pete Brown
Falls Creek
Oz


Hallgeir
2/9/2004 12:09:31 PM
[quoted text, click to view]

Thank you, Pete
This and your ansver to Barbara solved my problem.

mvh
Hallgeir

AddThis Social Bookmark Button