Jump to content

Recommended Posts

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 SF100001 and 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#)

);

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.