473,395 Members | 1,532 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Surely not!

I know I must be missing something pretty obvious, but what setting
should I change to get the correct length of my string ie why does the
select statement below return 1 when it looks fairly obvious that the
second string is a tad longer than 1

select len('a ')
select len('a ')
Jul 20 '05 #1
3 1932
From the Books Online:

<Excerpt href="tsqlref.chm::/ts_la-lz_3e7i.htm">

LEN

Returns the number of characters, rather than the number of bytes, of the
given string expression, excluding trailing blanks.

</Excerpt>

--
Hope this helps.

Dan Guzman
SQL Server MVP

"DMAC" <dr***@drmcl.free-online.co.uk> wrote in message
news:46**************************@posting.google.c om...
I know I must be missing something pretty obvious, but what setting
should I change to get the correct length of my string ie why does the
select statement below return 1 when it looks fairly obvious that the
second string is a tad longer than 1

select len('a ')
select len('a ')

Jul 20 '05 #2
DMAC (dr***@drmcl.free-online.co.uk) writes:
I know I must be missing something pretty obvious, but what setting
should I change to get the correct length of my string ie why does the
select statement below return 1 when it looks fairly obvious that the
second string is a tad longer than 1

select len('a ')
select len('a ')


In addition to Dan's response, if you need to know the length including
the trailing blanks, use the datalength() function. Beware that this
function returns the length in bytes, so if you use datalength on
Unicode data, you need to divide the result by two to get the length
in characters.

--
Erland Sommarskog, SQL Server MVP, so****@algonet.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp
Jul 20 '05 #3
Erland, thanks for adding this. I should have included the alternative
DATALENGTH function in my response.

--
Dan Guzman
SQL Server MVP

"Erland Sommarskog" <so****@algonet.se> wrote in message
news:Xn**********************@127.0.0.1...
DMAC (dr***@drmcl.free-online.co.uk) writes:
I know I must be missing something pretty obvious, but what setting
should I change to get the correct length of my string ie why does the
select statement below return 1 when it looks fairly obvious that the
second string is a tad longer than 1

select len('a ')
select len('a ')


In addition to Dan's response, if you need to know the length including
the trailing blanks, use the datalength() function. Beware that this
function returns the length in bytes, so if you use datalength on
Unicode data, you need to divide the result by two to get the length
in characters.

--
Erland Sommarskog, SQL Server MVP, so****@algonet.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp

Jul 20 '05 #4

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

Similar topics

3
by: Sandwick | last post by:
I am trying to change the size of a drawing so they are all 3x3. the script below is what i was trying to use to cut it in half ... I get errors. I can display the normal picture but not the...
7
by: Xerxes | last post by:
Hi, I have a link in my page that allows users to download an exe file. However, when I download and run it, it briefly displays the DOS box and nothing happens. In my php file, I have: ...
2
by: Richard Shea | last post by:
Hi - I'm writing a script which fetches a page from a web server and takes note of any set-cookies which are served in the headers so that when I next request a page I can send those cookies back...
4
by: oliver hadfield | last post by:
Hello all I am having a small problem wih a javascript, could anyone help me please 1. first of all this code requires a form f01 and textarea t01 <form name ="f01">
3
by: Rudi Cheow | last post by:
Hey folks, Something really doesn't make sense to me. Maybe you guys can figure it out: Code Set 1: <---START CODE---> <html>
1
by: Groove | last post by:
I have a typical Repeater that contains a Template (html table). The repeater / template lists many records and in the footer, I'd like to simply SUM up the $$ amounts from all the records in the...
10
by: Greg | last post by:
class a { public: int x; private: int y; } class b : public a {
1
by: gertrude | last post by:
I am a Computer Systems Engineer offering fast help with Java, C/C++, PHP, JSP, XML/XSL, SQL, web design, network administration, algorithms and more! http://www.homework911.150m.com
3
by: 6afraidbecause789 | last post by:
Think school - students - discipline interventions - misbehaviors - staff for this one....On a mainform frmStudentInterventions, I have linked a subform (sfrmMisbehaviors) with another subform...
10
by: Martin | last post by:
We are trying to create a stylesheet that works both for FF and MSIE. I've been googling a bit yesterday and found some hints (like using #margin-left or _margin-left for MSIE) but it seems these...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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...
0
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,...

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.