Link to home
Start Free TrialLog 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
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ty