Link to home
Create AccountLog in
Avatar of vbnetcoder
vbnetcoder

asked on

generating a key field

for a key in my table I am appending RACT to a number..

So the key would be like this:

RACT100000000000000000000

I would like the next id to be:

RACT100000000000000000001
etc


Is there something in the table create that I could make that happen so that they keep adding one each time? Or is there a better way to do in in my t-sql code where I am inserting?
Avatar of Scott Pletcher
Scott Pletcher
Flag of United States of America image

Use separate columns in the table for the 'RACT' value and the number.  Then you can use IDENTITY or a SEQUENCE to supply values to the number.  Use a concatenated column to return combined values to queries.  You can use a view or a computed column to combine the values.
Avatar of vbnetcoder
vbnetcoder

ASKER

How would I do it if I wrote in my T-SQL code?
ASKER CERTIFIED SOLUTION
Avatar of Mark Wills
Mark Wills
Flag of Australia image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
ty