Showing posts with label accidental. Show all posts
Showing posts with label accidental. Show all posts

Sunday, March 11, 2012

check constraint or rule for control characters

I'm trying to control the accidental entry of special characters (carriage
return) from getting into my data. I thought I could write a check
constraint like what follows
[name] <> '%' + char(13) + '%'
but this doesn't work. Tried several permutations but the carriage return
is always accepted when I enter the data through an access database table
view (control + enter).
If I can get the expression working I think the best way to implement would
be either a user defined datatype or a rule bound to the column.
Has anyone done this sort of thing, or know how?
Thanks
David LHow about
CharIndex(Char(13), [Name], 1) = 0
Or
[Name] Not Like '%' + Char(13) + '%'
Thomas
"DavinciCoder" <dal@.rlpi.com> wrote in message
news:uqpvUvuaFHA.2664@.TK2MSFTNGP15.phx.gbl...
> I'm trying to control the accidental entry of special characters (carriage
> return) from getting into my data. I thought I could write a check constr
aint
> like what follows
> [name] <> '%' + char(13) + '%'
> but this doesn't work. Tried several permutations but the carriage return
is
> always accepted when I enter the data through an access database table vie
w
> (control + enter).
> If I can get the expression working I think the best way to implement woul
d be
> either a user defined datatype or a rule bound to the column.
> Has anyone done this sort of thing, or know how?
> Thanks
>
> --
> David L
>|||Ok, the second works great thanks
"Thomas Coleman" <replyingroup@.anywhere.com> wrote in message
news:eh1KX0uaFHA.1152@.tk2msftngp13.phx.gbl...
> How about
> CharIndex(Char(13), [Name], 1) = 0
> Or
> [Name] Not Like '%' + Char(13) + '%'
>
> Thomas
>
> "DavinciCoder" <dal@.rlpi.com> wrote in message
> news:uqpvUvuaFHA.2664@.TK2MSFTNGP15.phx.gbl...
>|||David
You may want to check CHAR(10) as well.
"DavinciCoder" <dal@.rlpi.com> wrote in message
news:%23X6if6uaFHA.2884@.tk2msftngp13.phx.gbl...
> Ok, the second works great thanks
>
> "Thomas Coleman" <replyingroup@.anywhere.com> wrote in message
> news:eh1KX0uaFHA.1152@.tk2msftngp13.phx.gbl...
>