473,808 Members | 2,861 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to find records with length greater than 17

how do i write sql statment to find records with name greater than 17
characters.
Jun 27 '08 #1
5 35581
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
Jun 27 '08 #2

"Plamen Ratchev" <Pl****@SQLStud io.comwrote in message
news:t9******** *************** *******@speakea sy.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
Jun 27 '08 #3
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

Jun 27 '08 #4
On Apr 21, 3:36*pm, "Plamen Ratchev" <Pla...@SQLStud io.comwrote:
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.c om
Right - i dont want to include spaces.
I want to check where the first word is greater than 17
Jun 27 '08 #5
ci***@yahoo.com wrote:
>
On Apr 21, 3:36 pm, "Plamen Ratchev" <Pla...@SQLStud io.comwrote:
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.c om

Right - i dont want to include spaces.
I want to check where the first word is greater than 17
It won't do that. For example, the query above will also select the row
where namecol has a value of 'John Smithersonson'

So if Plamen's solution does not do what you want, then please some
example data and desired output.

--
Gert-Jan
Jun 27 '08 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
3576
by: Kueishiong Tu | last post by:
I have a network stream which I got from HttpWebResponse and does not support seeking, How do I find the length of the network stream? HttpWebResponse* response = dynamic_cast<HttpWebResponse*> (request->GetResponse()); // Gets the stream associated with the response. Stream* receiveStream = response->GetResponseStream(); int n = receiveStream->Read(responseArray, 0, responseString->Length);
11
60280
by: mailar | last post by:
Hi, I am using DB2 version 8.2 on Windows XP platform. I have a table 'EMP' with one field named 'NAME' of type CHAR , size 80. Also , I have a record with NAME='john' Now, when I try to find the length of the this name field DB2 returns 80 . Can someone tell me how do I find the actual length of this NAME
2
1116
by: Kueishiong Tu | last post by:
I have a network stream which I got from HttpWebResponse and does not support seeking, How do I find the length of the network stream? HttpWebResponse* response = dynamic_cast<HttpWebResponse*> (request->GetResponse()); // Gets the stream associated with the response. Stream* receiveStream = response->GetResponseStream(); int n = receiveStream->Read(responseArray, 0, responseString->Length);
2
1767
by: Joost Kraaijeveld | last post by:
I have a table with column1, column2, column3 and column4. How do I get all records, sorted by column4 that have the same column1,column2 and column3? TIA Joost ---------------------------(end of broadcast)---------------------------
1
1387
by: fatesgrasp | last post by:
Hi. This is my first time trying this site out. I'm stuck on a problem. I'm trying to find records in an access database with a date greater than todays date but it's pulling all records. Please advise. strSQL = "SELECT Schedule.StartTime, Schedule.Date, Schedule.EndTime, " strSQL = strSQL & "Students.FirstName, Routines.Routine " strSQL = strSQL & "FROM (Routines INNER JOIN (Students INNER JOIN Enrollments ON Students.StudentID =...
2
2553
by: raghunadhs | last post by:
hi every body! can u say "is there any built in method to find the length of an array", so that it should say how many elements are int that array. i used UBOUND method, but it gives the size of array not, how many elements are in that array. Thanks in advance, Regards: Raghunadhs.
4
1718
by: sunil | last post by:
How do I find the length of page in target iframe? I am looking for the code or give me idea to find the length
0
2977
by: mrsoft100 | last post by:
Dear Members I have written a program whose intention is to track fee payment by students in a school. the program is intended to track as many students as possible. My program works very well and it is linked to a database (Access 2003). I can move from one document to the next or previouse, I can exit, enter new records and even delet. the codes are working very well. however after many entris have been done, it becomes to tidious to move...
2
2589
by: karimufeed | last post by:
I am working on an access project for pension calculation. I want to find total length of service between two dates. i.e. if the Date of entry into service is 15/3/1980 and the date of retirement will be 31/1/2010 then the total length of service will be 29 years, 10 months, 17 days. Kindly help me how to find the length of service in above said format by using VB code in an access project.
0
9600
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10374
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10374
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10114
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9196
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7651
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5548
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3859
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3011
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.