katiewebster7
asked on
SQL Server 2000 Data Types XNNNN
In sql server 2000 (windows), is it possible to set the data type when creating a new table to have a specific letter followed by four numbers, ie. J1004? It does not need to auto increment.
Example:
CREATE TABLE dbo.Employee (
vEmployeeID VARCHAR(5) UNIQUEIDENTIFIER PRIMARY KEY NONCLUSTERED,
Example:
CREATE TABLE dbo.Employee (
vEmployeeID VARCHAR(5) UNIQUEIDENTIFIER PRIMARY KEY NONCLUSTERED,
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
sorry - I just reread your post - yes, it seems like that would work - however, I am curious if that is truly the only way...
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Ok, only "J" makes:
CREATE TABLE dbo.Employee (
vEmployeeID VARCHAR(5) PRIMARY KEY NONCLUSTERED CHECK (vEmployeeID like 'J[0-9][0-9][0-9][0-9]'))
Hope that helps ...
CREATE TABLE dbo.Employee (
vEmployeeID VARCHAR(5) PRIMARY KEY NONCLUSTERED CHECK (vEmployeeID like 'J[0-9][0-9][0-9][0-9]'))
Hope that helps ...
... as A3 said ... beating me by ten minutes ... :-)
>however, I am curious if that is truly the only way...
no, that's indeed not the only way (but the most effective one).
alternative would be a trigger that performs the same "check", and rolls back the transaction and raises an error to information the user (ie application) with the problem.
no, that's indeed not the only way (but the most effective one).
alternative would be a trigger that performs the same "check", and rolls back the transaction and raises an error to information the user (ie application) with the problem.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks a bunch - especially to angelIII !
ASKER
I am wanting to create a table that will only accept data for that field that begins with a specific letter, say, "J", followed by four numbers...