Connecting Tech Pros Worldwide Help | Site Map

plz suggest me the query

  #1  
Old August 15th, 2008, 07:45 PM
mo/-/sin
Guest
 
Posts: n/a
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, 08:35 PM
nidaar
Guest
 
Posts: n/a

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, 08:35 PM
--CELKO--
Guest
 
Posts: n/a

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]'),
Closed Thread


Similar Threads
Thread Thread Starter Forum Replies Last Post
query to search even when user skips in between text kkshansid answers 4 February 5th, 2009 04:35 AM
plz suggest reg. cursors shankarsunmicrosys answers 0 November 24th, 2008 04:14 PM
Problem in query navneetkaur answers 1 September 3rd, 2007 03:30 PM
Performance of datatable.select() func against database query orthe xquery Mukesh answers 2 June 14th, 2007 08:15 AM