Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Create Check contraint for CHR(10) and CHR(13)

Status
Not open for further replies.

phweston

Programmer
May 8, 2003
38
0
0
Hi,
I need to create a contraint to check for CHr(10) and chr(13) at the beginning and end of a text field. I was given this code to use, but I get the error message "'chr' is not a recognized function name".


Using the following example:
The Table name is CustomerName
The Field Name is CustName and is data type nvarchar


ALTER TABLE [CustomerName]
ADD CONSTRAINT [Ck_CustName]
CHECK(SUBSTRING([CustName], -1, 1) <> chr(13) and
SUBSTRING([CustName], -1, 1) <> chr(10) and
SUBSTRING([CustName], 1, 1) <> chr(13) and
SUBSTRING([CustName], 1, 1) <> chr(10));

What am I doing wrong and how to do fix this?

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top