SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 quick question
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

stumbling
Posting Yak Master

104 Posts

Posted - 04/15/2007 :  03:14:39  Show Profile  Reply with Quote
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)

Singapore
17642 Posts

Posted - 04/15/2007 :  03:17:13  Show Profile  Reply with Quote
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

Go to Top of Page

stumbling
Posting Yak Master

104 Posts

Posted - 04/15/2007 :  03:20:09  Show Profile  Reply with Quote
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?
Go to Top of Page

khtan
In (Som, Ni, Yak)

Singapore
17642 Posts

Posted - 04/15/2007 :  03:25:42  Show Profile  Reply with Quote
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

Go to Top of Page

stumbling
Posting Yak Master

104 Posts

Posted - 04/15/2007 :  03:28:11  Show Profile  Reply with Quote
Thanks that makes more sence appreciate your very quick response now Im back to work again bummer.
Go to Top of Page

khtan
In (Som, Ni, Yak)

Singapore
17642 Posts

Posted - 04/15/2007 :  03:31:22  Show Profile  Reply with Quote
the formatting can also be done easily on your front end or reporting tool. Why don't you do it there ?


KH

Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.09 seconds. Powered By: Snitz Forums 2000