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 |
stumbling
Posting Yak Master
104 Posts |
Posted - 2007-04-15 : 03:14:39
|
I can not for the life of me get a count to work in the following statement? Can i use count like this?select right(replicate('0', 10) + (count(Recordtype)) ,10) from dataexport where Recordtype = 'T'Thanks |
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2007-04-15 : 03:17:13
|
quote: Originally posted by stumbling I can not for the life of me get a count to work in the following statement? Can i use count like this?select right(replicate('0', 10) + (count(Recordtype)) ,10) from dataexport where Recordtype = 'T'Thanks
Yes. This seems ok. Do you get any error messages ? KH |
|
|
stumbling
Posting Yak Master
104 Posts |
Posted - 2007-04-15 : 03:20:09
|
My goal is to get it to return the count of T type records including added leading zeros but all i get is the count and no leading zeros and no errors? |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2007-04-15 : 03:25:42
|
convert the count(*) to varchar before concat with the '0'. select right(replicate('0', 10) + (convert(varchar(10), count(Recordtype))), 10) from dataexport where Recordtype = 'T' KH |
|
|
stumbling
Posting Yak Master
104 Posts |
Posted - 2007-04-15 : 03:28:11
|
Thanks that makes more sence appreciate your very quick response now Im back to work again bummer. |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2007-04-15 : 03:31:22
|
the formatting can also be done easily on your front end or reporting tool. Why don't you do it there ? KH |
|
|
|
|
|
|
|