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
 SQL Server 2005 Forums
 SQL Server Administration (2005)
 INSERT ERRORS..

Author  Topic 

Hinduson
Yak Posting Veteran

69 Posts

Posted - 2013-09-30 : 14:50:12
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
Master Smack Fu Yak Hacker

3873 Posts

Posted - 2013-09-30 : 14:56:54
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

69 Posts

Posted - 2013-10-01 : 02:14:02
Thanks James


Best Regards.
Go to Top of Page

Hinduson
Yak Posting Veteran

69 Posts

Posted - 2013-10-01 : 02:41:20
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
   

- Advertisement -