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
 General SQL Server Forums
 New to SQL Server Programming
 Re: Select query

Author  Topic 

dr223
Constraint Violating Yak Guru

444 Posts

Posted - 2010-02-18 : 10:27:39
Hallo,

When I have the select query below;

Select dbo.tblProjectPractices.PracticeGPID AS GPID
from dbo.tblProjectPractices


It provides me with values;

824
11
5678

I want to format this so that it should be

000824
000011
005678

how can I do this?


Thanks

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-02-18 : 10:35:30
[code]Select RIGHT ('000000'+ CAST(dbo.tblProjectPractices.PracticeGPID AS varchar(10)),6) AS GPID
from dbo.tblProjectPractices[/code]

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

dr223
Constraint Violating Yak Guru

444 Posts

Posted - 2010-02-18 : 11:04:00
Thanks
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-02-18 : 11:06:19
welcome

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -