SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2005 Forums
 SQL Server Administration (2005)
 INSERT ERRORS..
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Hinduson
Yak Posting Veteran

Ghana
57 Posts

Posted - 09/30/2013 :  14:50:12  Show Profile  Reply with Quote
Please i get this error statement after i execute the syntax below. Can someone help me out. And i created a rule and the rule is, and i binded the rule to the table and when i try to insert values into the table i get this error message all stated below respectively.

INSERT INTO SUPPLIER_SUPPLIERDETAILS (FirstName, LastName, Address, Phone, Country)
VALUES ('Babel','Lebab','5th melon street','125986324','Adisababa')


CREATE RULE PATTERN_RULE
AS
@VALUE LIKE '_-%[0-9][0-9]-[0-9][0-9][0-9]-[0-9][0-9][0-9][0-9]-[0-9][0-9][0-9]-[0-9][0-9][0-9]'


EXEC SP_BINDRULE 'PATTERN_RULE','SUPPLIER_SUPPLIERDETAILS.[PHONE]'


Msg 513, Level 16, State 0, Line 1
A column insert or update conflicts with a rule imposed by a previous CREATE RULE statement. The statement was terminated. The conflict occurred in database 'HERESHOP', table 'dbo.SUPPLIER_SUPPLIERDETAILS', column 'Phone'.
The statement has been terminated.



Best Regards.

James K
Flowing Fount of Yak Knowledge

3326 Posts

Posted - 09/30/2013 :  14:56:54  Show Profile  Reply with Quote
This is because your rule calls for a very specific pattern. All of the following match the pattern, but the '125986324' that you are trying to insert does not.
'X-BlaBla12-123-1234-123-123'
'Y--111-1111-111-111'
'Z---845-7971-200-838'
See here for details of pattern-matching in SQL: http://technet.microsoft.com/en-us/library/ms179859.aspx
Go to Top of Page

Hinduson
Yak Posting Veteran

Ghana
57 Posts

Posted - 10/01/2013 :  02:14:02  Show Profile  Reply with Quote
Thanks James


Best Regards.
Go to Top of Page

Hinduson
Yak Posting Veteran

Ghana
57 Posts

Posted - 10/01/2013 :  02:41:20  Show Profile  Reply with Quote
Am still having problems. Can I get a help on how to create a rule that will suit as an answer to the question below please. Or should i use a check constraint? Please Advice and express how?

* Phone Should not be left Blank and should be in the following format. '[0-9][0-9]-[0-9][0-9][0-9]-[0-9][0-9][0-9][0-9]-[0-9][0-9][0-9]-[0-9][0-9][0-9]'


Best Regards.
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.03 seconds. Powered By: Snitz Forums 2000