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
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Format a Data

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2005-04-15 : 08:01:06
Adrian writes "Hi,

I have a problem which i hope i can find an answer in this forum. This are my requirements. I have a table which i'm required to make at just say ID unique. In this ID column i require to insert a running number plus a standard prefix which could be a fix 10 digit value like this "0000000000". So when i insert into the database i would like the data to be "0000000001" and as i add on i want to keep the standard. When the running number reaches like 10 it should be "0000000010", 100 "0000000100" and so on.

How do i achieve this in SQL Server.. I'm currently using SQL 2000

Thank you.."

cshah1
Constraint Violating Yak Guru

347 Posts

Posted - 2005-04-15 : 09:58:41
This might give you some idea how to do this..

http://sqlteam.com/item.asp?ItemID=1417
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2005-04-15 : 10:18:32
Why are you worried about storing data in presentation form in the database?

Just use and IDENTIY Column and presnt the data with

SELECT RIGHT(REPLICATE('0',10)+CONVERT(varchar(10),IdentityCol),10)



Brett

8-)
Go to Top of Page
   

- Advertisement -