Connecting Tech Pros Worldwide Help | Site Map

plz suggest me the query

 
LinkBack Thread Tools Search this Thread
  #1  
Old August 15th, 2008, 06:45 PM
mo/-/sin
Guest
 
Posts: n/a
Default plz suggest me the query

plz tel me that : suppose that i made a table in sql server 2005 an
there is a column name "department id"..... i want that who so ever
enters the value in this column shoul prefix "DEP" and then 3nos......
it means that the format should be like this "DEP***" WHERE * ARE THE
NOS........ OR is ther any way so that it wil automatically prefix
"DEP"...otherwise it wil throw an error........

  #2  
Old August 15th, 2008, 07:35 PM
nidaar
Guest
 
Posts: n/a
Default Re: plz suggest me the query

CREATE TABLE [dbo].[Departments](
[DepartmentID] [nchar](6) NULL
) ON [PRIMARY]

GO

ALTER TABLE [dbo].[Departments] WITH CHECK ADD CONSTRAINT
[CK_Departments] CHECK (([DepartmentID] like 'DEP[0-9][0-9][0-9]'))
GO

ALTER TABLE [dbo].[Departments] CHECK CONSTRAINT [CK_Departments]
GO
  #3  
Old August 15th, 2008, 07:35 PM
--CELKO--
Guest
 
Posts: n/a
Default Re: plz suggest me the query

CREATE TABLE Foobar
( ..
department_id CHAR(6) NOT NULL
CHECK (department_id LIKE 'DEP[0-9][0-9][0-9]'),
 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,989 network members.