Click to See Complete Forum and Search --> : SQL datalength problem


IxxI
08-04-2005, 04:55 AM
I wish to select records from a recordset that have a length of 3 characters (the column is nvarchar) but I can't find a way to do it I've tried:


SELECT * FROM table WHERE row1 = 'thisval' AND datalength(row2) = 3"


and:


SELECT * FROM table WHERE row1 = 'thisval' AND datalength(rtrim((row2)) = 3"


and even:


SELECT * FROM table WHERE row1 = 'thisval' AND Length(row2) = 3"


but none of those seems to work - does anyoone know how to do this?
Thanks in advance,
IxxI

buntine
08-04-2005, 06:06 AM
The actual syntax may differ among databases.

SQL Server and (I think) MS Access bnoth use the LEN function.

SELECT * FROM table WHERE row1 = 'thisval' AND LEN(row2) = 3;

Regards.

IxxI
08-05-2005, 03:59 AM
Thanks Buntine, right as usual :)

buntine
08-05-2005, 05:43 AM
;) Cheers.