phweston
Programmer
- May 8, 2003
- 38
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?
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?