Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 sql constraint

Author  Topic 

HelpingOthers
Starting Member

3 Posts

Posted - 2012-01-03 : 17:03:16
Hi I'm new and haven't contributed to the forums yet but if anyone would be kind to help me with this problem. I have searched everywhere trying to learn how to solve this.

I need to create a constraint on a create table that stops the user from entering the letters J,K,L,N in the table called BANK and column UserID.

This could be a simple solution but when you don't know how it's difficult and frustrating please help.

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2012-01-03 : 17:15:20
There are good examples in the CREATE TABLE documentation in BOL: http://msdn.microsoft.com/en-us/library/ms174979.aspx

Examples are always near the bottom of the topic.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

HelpingOthers
Starting Member

3 Posts

Posted - 2012-01-03 : 17:33:15
ok thanks Tara a lot of useful information on there. I shall go indulge.
Go to Top of Page

whatamouth
Starting Member

16 Posts

Posted - 2012-01-04 : 04:09:21
create table BANK
(
UserID varchar(10),
constraint test_constraint check (UserID not like '%[j-n]%')
)




Neil Matias
neilmatias@yahoo.com
Go to Top of Page
   

- Advertisement -