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 |
|
igorblackbelt
Constraint Violating Yak Guru
407 Posts |
Posted - 2006-04-17 : 14:30:20
|
| Guys -Is there a way to automatically generate a number in a table for each new record inserted ?I'm trying to create a automatic customer number for each new client registered on the intranet web site.Thanks!---Thanks!Igor. |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2006-04-17 : 14:34:16
|
| You can use the identity option on a column. CREATE TABLE Table1 (Column1 int IDENTITY(1, 1) NOT NULL, Column2 varchar(30), ...)Tara Kizeraka tduggan |
 |
|
|
Srinika
Master Smack Fu Yak Hacker
1378 Posts |
Posted - 2006-04-17 : 14:37:18
|
| Yes Make Identity = Yes and select a seedSrinika |
 |
|
|
igorblackbelt
Constraint Violating Yak Guru
407 Posts |
Posted - 2006-04-19 : 11:30:02
|
| Never used Identity before, I'll give it a try... Since they want this client number to follow a certain patern, is it possible to add like 3 letters in front of it, plus some digits at the end, that will be generated thru some business logic, mixed with current date ?---Thanks!Igor. |
 |
|
|
Srinika
Master Smack Fu Yak Hacker
1378 Posts |
Posted - 2006-04-19 : 11:42:38
|
| Unfortunately Identity is Integer.as far as I knowEither u have to have a UDF to create the sequential - varchar that u wantor u have to have a composite column with one haveing character data and identity col having Integer dataMay be there is another workaroundSrinika |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2006-04-20 : 02:00:35
|
quote: Originally posted by igorblackbelt Never used Identity before, I'll give it a try... Since they want this client number to follow a certain patern, is it possible to add like 3 letters in front of it, plus some digits at the end, that will be generated thru some business logic, mixed with current date ?---Thanks!Igor.
Refer thishttp://www.sqlteam.com/forums/topic.asp?TOPIC_ID=57069MadhivananFailing to plan is Planning to fail |
 |
|
|
igorblackbelt
Constraint Violating Yak Guru
407 Posts |
Posted - 2006-04-21 : 14:11:21
|
| great, I think this is what I need, it's easier than I thought. thanks man!---Thanks!Igor. |
 |
|
|
|
|
|
|
|