|
Prev: first minimum date in the column for each distinct column a value
Next: Using findstr on SQL 2005 ERRORLOG file
From: ciojr on 21 Apr 2008 15:07 how do i write sql statment to find records with name greater than 17 characters.
From: Plamen Ratchev on 21 Apr 2008 15:36 The LEN function returns the number of characters excluding trailing blanks: SELECT namecol FROM Foo WHERE LEN(namecol) > 17; The DATALENGTH function returns the number of bytes. HTH, Plamen Ratchev http://www.SQLStudio.com
From: John Sheppard on 22 Apr 2008 02:23 "Plamen Ratchev" <Plamen(a)SQLStudio.com> wrote in message news:t9ednRsfVu9McZHVnZ2dnUVZ_jSdnZ2d(a)speakeasy.net... > The LEN function returns the number of characters excluding trailing > blanks: > > SELECT namecol > FROM Foo > WHERE LEN(namecol) > 17; > > The DATALENGTH function returns the number of bytes. > > HTH, > > Plamen Ratchev > http://www.SQLStudio.com Wouldnt it matter if the field was in unicode then? What do you do if you want to include the spaces? I dont really want to know I just thought it weird that len would behave like that...(Im an SQL server noob) John Sheppard
From: Plamen Ratchev on 22 Apr 2008 08:34 There is no difference when you use LEN with Unicode column. If you need to include the spaces you can use DATALENGTH. The only considerations is that it returns number of bytes, so for NVARCHAR/NCHAR/NTEXT will return double the length. HTH, Plamen Ratchev http://www.SQLStudio.com
From: ciojr on 22 Apr 2008 12:15
On Apr 21, 3:36 pm, "Plamen Ratchev" <Pla...(a)SQLStudio.com> wrote: > The LEN function returns the number of characters excluding trailing blanks: > > SELECT namecol > FROM Foo > WHERE LEN(namecol) >17; > > The DATALENGTH function returns the number of bytes. > > HTH, > > Plamen Ratchevhttp://www.SQLStudio.com Right - i dont want to include spaces. I want to check where the first word is greater than 17 |