metalpain Posted October 5, 2008 Share Posted October 5, 2008 Hello, I am trying to create a unique primary key that has alpha and numeric values that auto generate, so far i can get the numbers to auto generate but i have no idea how to add alpha characters to it. basic what i want to do is add for example two alpha characters SF in front of the auto incremented numbers so for example SF100000 then so on. is it possible to do this? below is a copy of my script. thankyou. -- Create Staff Table -- CREATE TABLE Staff( Staff# BIGINT IDENTITY(100000,1) not null, Staff_name varchar(25)not null, Staff_surname varchar(25)not null, Staff_phone varchar(10), Staff_Address varchar(50), Staff_postcode numeric (4), Staff_Salary numeric (8,2), Staff_Postion varchar (30), constraint STAFF_PK PRIMARY KEY (staff#) ); Quote Link to comment https://forums.phpfreaks.com/topic/127100-unique-primary-key-alpha-and-numeric/ Share on other sites More sharing options...
Barand Posted October 5, 2008 Share Posted October 5, 2008 This is a MySQL forum BTW, that is MSSQL But why don't you store the alpha portion in a separate column and concatenate on output. Quote Link to comment https://forums.phpfreaks.com/topic/127100-unique-primary-key-alpha-and-numeric/#findComment-657453 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.