<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
		>
<channel>
	<title>Comments on: SQL SERVER &#8211; Find Length of Text Field</title>
	<atom:link href="http://blog.sqlauthority.com/2007/06/20/sql-server-find-length-of-text-field/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.sqlauthority.com/2007/06/20/sql-server-find-length-of-text-field/</link>
	<description>Notes of a SQL Server MVP and Database Administrator</description>
	<lastBuildDate>Wed, 17 Mar 2010 03:19:03 +0000</lastBuildDate>
	<generator>http://wordpress.com/</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: David</title>
		<link>http://blog.sqlauthority.com/2007/06/20/sql-server-find-length-of-text-field/#comment-63016</link>
		<dc:creator>David</dc:creator>
		<pubDate>Tue, 16 Mar 2010 14:54:29 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/06/20/sql-server-find-length-of-text-field/#comment-63016</guid>
		<description>Just what I needed, thank you</description>
		<content:encoded><![CDATA[<p>Just what I needed, thank you</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mike</title>
		<link>http://blog.sqlauthority.com/2007/06/20/sql-server-find-length-of-text-field/#comment-61276</link>
		<dc:creator>Mike</dc:creator>
		<pubDate>Tue, 16 Feb 2010 15:28:30 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/06/20/sql-server-find-length-of-text-field/#comment-61276</guid>
		<description>Hello,

I have a table which has field1, field2 and field3 columns of type int, the combination of those columns represent 10 digit phone number. I know field3 always have 4 digits, but MS SQL trims the right most 0s. all i am tring to acheive is to provide the user with one field 10 digit number. 

here is my query:

INSERT INTO [Info Direct Res new]
SELECT &#039;Info Direct&#039;, /* Datbase Name */
DECLARE @MAX_FIELD_LEN int;
DECLARE @fieldLength int;
SET @MAX_FIELD_LEN=4;
SET @fieldLength = len(Cast(field3 as varchar));
cast(field1 as varchar)+cast(field2 as varchar)+RIGHT(&#039;0&#039;,@MAX_FIELD_LEN-@fieldLength)+Cast(field3 as varchar), /* Phone Number */
field5, /*First name*/ 
field6, /*Last Name*/
ISNULL(field8,&#039;&#039;) + &#039; &#039; + ISNULL(field9,&#039;&#039;)+ &#039; &#039; + ISNULL(field10,&#039;&#039;)+ &#039; &#039; + ISNULL(field11,&#039;&#039;)+ &#039; &#039; + ISNULL(field12,&#039;&#039;), /* Full Address */
field13, /* city */
field14, /* province */
field15, /* postal code */
&#039; &#039;
from stcir1001

I get syntax error where i say declare 

thanks,</description>
		<content:encoded><![CDATA[<p>Hello,</p>
<p>I have a table which has field1, field2 and field3 columns of type int, the combination of those columns represent 10 digit phone number. I know field3 always have 4 digits, but MS SQL trims the right most 0s. all i am tring to acheive is to provide the user with one field 10 digit number. </p>
<p>here is my query:</p>
<p>INSERT INTO [Info Direct Res new]<br />
SELECT &#8216;Info Direct&#8217;, /* Datbase Name */<br />
DECLARE @MAX_FIELD_LEN int;<br />
DECLARE @fieldLength int;<br />
SET @MAX_FIELD_LEN=4;<br />
SET @fieldLength = len(Cast(field3 as varchar));<br />
cast(field1 as varchar)+cast(field2 as varchar)+RIGHT(&#8216;0&#8242;,@MAX_FIELD_LEN-@fieldLength)+Cast(field3 as varchar), /* Phone Number */<br />
field5, /*First name*/<br />
field6, /*Last Name*/<br />
ISNULL(field8,&#8221;) + &#8216; &#8216; + ISNULL(field9,&#8221;)+ &#8216; &#8216; + ISNULL(field10,&#8221;)+ &#8216; &#8216; + ISNULL(field11,&#8221;)+ &#8216; &#8216; + ISNULL(field12,&#8221;), /* Full Address */<br />
field13, /* city */<br />
field14, /* province */<br />
field15, /* postal code */<br />
&#8216; &#8216;<br />
from stcir1001</p>
<p>I get syntax error where i say declare </p>
<p>thanks,</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Madhivanan</title>
		<link>http://blog.sqlauthority.com/2007/06/20/sql-server-find-length-of-text-field/#comment-61259</link>
		<dc:creator>Madhivanan</dc:creator>
		<pubDate>Tue, 16 Feb 2010 13:35:25 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/06/20/sql-server-find-length-of-text-field/#comment-61259</guid>
		<description>It is formation issue. If you use front end application do the formation there</description>
		<content:encoded><![CDATA[<p>It is formation issue. If you use front end application do the formation there</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Madhivanan</title>
		<link>http://blog.sqlauthority.com/2007/06/20/sql-server-find-length-of-text-field/#comment-61257</link>
		<dc:creator>Madhivanan</dc:creator>
		<pubDate>Tue, 16 Feb 2010 13:33:59 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/06/20/sql-server-find-length-of-text-field/#comment-61257</guid>
		<description>When the value is NULL, the size is also NULL</description>
		<content:encoded><![CDATA[<p>When the value is NULL, the size is also NULL</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Madhivanan</title>
		<link>http://blog.sqlauthority.com/2007/06/20/sql-server-find-length-of-text-field/#comment-61254</link>
		<dc:creator>Madhivanan</dc:creator>
		<pubDate>Tue, 16 Feb 2010 13:32:24 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/06/20/sql-server-find-length-of-text-field/#comment-61254</guid>
		<description>Note that there is no such datatype as text(max)

How did you insert data?

Can you post the code?</description>
		<content:encoded><![CDATA[<p>Note that there is no such datatype as text(max)</p>
<p>How did you insert data?</p>
<p>Can you post the code?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: pm</title>
		<link>http://blog.sqlauthority.com/2007/06/20/sql-server-find-length-of-text-field/#comment-61015</link>
		<dc:creator>pm</dc:creator>
		<pubDate>Thu, 11 Feb 2010 14:01:30 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/06/20/sql-server-find-length-of-text-field/#comment-61015</guid>
		<description>This is great!

But how can I find out the MAXSIZE of the field in question? 

We have recently updated our DB to increase the size of certain fields.  I need to check if the user updated their DB before performing any work on those fields.</description>
		<content:encoded><![CDATA[<p>This is great!</p>
<p>But how can I find out the MAXSIZE of the field in question? </p>
<p>We have recently updated our DB to increase the size of certain fields.  I need to check if the user updated their DB before performing any work on those fields.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Gilad</title>
		<link>http://blog.sqlauthority.com/2007/06/20/sql-server-find-length-of-text-field/#comment-60203</link>
		<dc:creator>Gilad</dc:creator>
		<pubDate>Mon, 25 Jan 2010 17:20:49 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/06/20/sql-server-find-length-of-text-field/#comment-60203</guid>
		<description>Hey Andazi,
Change the query to 

column1+column2+cast(column3/100 as varchar(50))

As the cast is only getting the first 20 characters</description>
		<content:encoded><![CDATA[<p>Hey Andazi,<br />
Change the query to </p>
<p>column1+column2+cast(column3/100 as varchar(50))</p>
<p>As the cast is only getting the first 20 characters</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tom</title>
		<link>http://blog.sqlauthority.com/2007/06/20/sql-server-find-length-of-text-field/#comment-60143</link>
		<dc:creator>Tom</dc:creator>
		<pubDate>Sat, 23 Jan 2010 15:03:34 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/06/20/sql-server-find-length-of-text-field/#comment-60143</guid>
		<description>You guys explained how to change the data amount being returned directly in SQL server, but what about the amount being returned in an ASP page?</description>
		<content:encoded><![CDATA[<p>You guys explained how to change the data amount being returned directly in SQL server, but what about the amount being returned in an ASP page?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Carrie</title>
		<link>http://blog.sqlauthority.com/2007/06/20/sql-server-find-length-of-text-field/#comment-59958</link>
		<dc:creator>Carrie</dc:creator>
		<pubDate>Tue, 19 Jan 2010 22:31:23 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/06/20/sql-server-find-length-of-text-field/#comment-59958</guid>
		<description>THIS HELPED ME SO MUCH - THANK YOU!!!</description>
		<content:encoded><![CDATA[<p>THIS HELPED ME SO MUCH &#8211; THANK YOU!!!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Andazi</title>
		<link>http://blog.sqlauthority.com/2007/06/20/sql-server-find-length-of-text-field/#comment-59787</link>
		<dc:creator>Andazi</dc:creator>
		<pubDate>Fri, 15 Jan 2010 10:21:22 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/06/20/sql-server-find-length-of-text-field/#comment-59787</guid>
		<description>Please help.
Need to add/combine 3 columns 

Column1              column                  column3
eddie                   lewis                      125.87456

query is select :

column1+column2+cast(column3/100 as varchar(20))

returns -  eddielewis1.25874  i.e missing last 2 digits of column3 ...... please help

Thanks</description>
		<content:encoded><![CDATA[<p>Please help.<br />
Need to add/combine 3 columns </p>
<p>Column1              column                  column3<br />
eddie                   lewis                      125.87456</p>
<p>query is select :</p>
<p>column1+column2+cast(column3/100 as varchar(20))</p>
<p>returns &#8211;  eddielewis1.25874  i.e missing last 2 digits of column3 &#8230;&#8230; please help</p>
<p>Thanks</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Devesh</title>
		<link>http://blog.sqlauthority.com/2007/06/20/sql-server-find-length-of-text-field/#comment-59732</link>
		<dc:creator>Devesh</dc:creator>
		<pubDate>Thu, 14 Jan 2010 12:46:15 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/06/20/sql-server-find-length-of-text-field/#comment-59732</guid>
		<description>Thanks a lot for such a useful tip.</description>
		<content:encoded><![CDATA[<p>Thanks a lot for such a useful tip.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Lana</title>
		<link>http://blog.sqlauthority.com/2007/06/20/sql-server-find-length-of-text-field/#comment-59480</link>
		<dc:creator>Lana</dc:creator>
		<pubDate>Fri, 08 Jan 2010 15:13:54 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/06/20/sql-server-find-length-of-text-field/#comment-59480</guid>
		<description>Hi!  This is not the first time your posts help me.  Thank you so much!</description>
		<content:encoded><![CDATA[<p>Hi!  This is not the first time your posts help me.  Thank you so much!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Bhargav</title>
		<link>http://blog.sqlauthority.com/2007/06/20/sql-server-find-length-of-text-field/#comment-57654</link>
		<dc:creator>Bhargav</dc:creator>
		<pubDate>Tue, 17 Nov 2009 03:07:36 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/06/20/sql-server-find-length-of-text-field/#comment-57654</guid>
		<description>Really great tip.
Thanks mate.</description>
		<content:encoded><![CDATA[<p>Really great tip.<br />
Thanks mate.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: UCMueller</title>
		<link>http://blog.sqlauthority.com/2007/06/20/sql-server-find-length-of-text-field/#comment-57522</link>
		<dc:creator>UCMueller</dc:creator>
		<pubDate>Wed, 11 Nov 2009 10:42:25 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/06/20/sql-server-find-length-of-text-field/#comment-57522</guid>
		<description>@ran

UPDATE tab SET col = RIGHT(&#039;000000&#039; + col, 6)</description>
		<content:encoded><![CDATA[<p>@ran</p>
<p>UPDATE tab SET col = RIGHT(&#8216;000000&#8242; + col, 6)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Brian Tkatch</title>
		<link>http://blog.sqlauthority.com/2007/06/20/sql-server-find-length-of-text-field/#comment-56630</link>
		<dc:creator>Brian Tkatch</dc:creator>
		<pubDate>Mon, 12 Oct 2009 20:59:15 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/06/20/sql-server-find-length-of-text-field/#comment-56630</guid>
		<description>@ran

Is this a VARCHAR field?

UPDATE tab SET col = &#039;00&#039; + col WHERE LEN(col) = 4;</description>
		<content:encoded><![CDATA[<p>@ran</p>
<p>Is this a VARCHAR field?</p>
<p>UPDATE tab SET col = &#8216;00&#8242; + col WHERE LEN(col) = 4;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: ran</title>
		<link>http://blog.sqlauthority.com/2007/06/20/sql-server-find-length-of-text-field/#comment-56605</link>
		<dc:creator>ran</dc:creator>
		<pubDate>Mon, 12 Oct 2009 05:14:49 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/06/20/sql-server-find-length-of-text-field/#comment-56605</guid>
		<description>any one there 
plz reply</description>
		<content:encoded><![CDATA[<p>any one there<br />
plz reply</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: ran</title>
		<link>http://blog.sqlauthority.com/2007/06/20/sql-server-find-length-of-text-field/#comment-56575</link>
		<dc:creator>ran</dc:creator>
		<pubDate>Sat, 10 Oct 2009 11:20:54 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/06/20/sql-server-find-length-of-text-field/#comment-56575</guid>
		<description>can anybody help me in using length function
how i can make any field have 4 digits (e.g 7456)
to 6 digits(i.e 007456) in my data base using sql query so that every field with length 4 is changed to length 6
but zero should come in front</description>
		<content:encoded><![CDATA[<p>can anybody help me in using length function<br />
how i can make any field have 4 digits (e.g 7456)<br />
to 6 digits(i.e 007456) in my data base using sql query so that every field with length 4 is changed to length 6<br />
but zero should come in front</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rajesh</title>
		<link>http://blog.sqlauthority.com/2007/06/20/sql-server-find-length-of-text-field/#comment-56344</link>
		<dc:creator>Rajesh</dc:creator>
		<pubDate>Fri, 02 Oct 2009 10:07:15 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/06/20/sql-server-find-length-of-text-field/#comment-56344</guid>
		<description>Good tips!!! 
Thanks bro</description>
		<content:encoded><![CDATA[<p>Good tips!!!<br />
Thanks bro</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Kunal Shah</title>
		<link>http://blog.sqlauthority.com/2007/06/20/sql-server-find-length-of-text-field/#comment-54789</link>
		<dc:creator>Kunal Shah</dc:creator>
		<pubDate>Wed, 12 Aug 2009 16:46:43 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/06/20/sql-server-find-length-of-text-field/#comment-54789</guid>
		<description>Good work !!</description>
		<content:encoded><![CDATA[<p>Good work !!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Hozher</title>
		<link>http://blog.sqlauthority.com/2007/06/20/sql-server-find-length-of-text-field/#comment-53885</link>
		<dc:creator>Hozher</dc:creator>
		<pubDate>Mon, 20 Jul 2009 16:13:21 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/06/20/sql-server-find-length-of-text-field/#comment-53885</guid>
		<description>Hello!

But, when the field is null ?
how can i know the size of a field, have or not have data in the table ??

Thanks!</description>
		<content:encoded><![CDATA[<p>Hello!</p>
<p>But, when the field is null ?<br />
how can i know the size of a field, have or not have data in the table ??</p>
<p>Thanks!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Imran Mohammed</title>
		<link>http://blog.sqlauthority.com/2007/06/20/sql-server-find-length-of-text-field/#comment-53481</link>
		<dc:creator>Imran Mohammed</dc:creator>
		<pubDate>Mon, 06 Jul 2009 06:21:45 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/06/20/sql-server-find-length-of-text-field/#comment-53481</guid>
		<description>@Chaminda,

Open SQL Server Management Studio
Go to Tools - Options (Tools exists at the top left of SSMS)
Expand Query Results
	Expand SQL Server
		Click on Results to Grid

On right side, Set Value for :
Maximum Characters retrieved : Set a higher value.

Because of this, SQL Server is returning fewer characters. Change this value to a higher value and see the difference

~ IM.</description>
		<content:encoded><![CDATA[<p>@Chaminda,</p>
<p>Open SQL Server Management Studio<br />
Go to Tools &#8211; Options (Tools exists at the top left of SSMS)<br />
Expand Query Results<br />
	Expand SQL Server<br />
		Click on Results to Grid</p>
<p>On right side, Set Value for :<br />
Maximum Characters retrieved : Set a higher value.</p>
<p>Because of this, SQL Server is returning fewer characters. Change this value to a higher value and see the difference</p>
<p>~ IM.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Chaminda</title>
		<link>http://blog.sqlauthority.com/2007/06/20/sql-server-find-length-of-text-field/#comment-53478</link>
		<dc:creator>Chaminda</dc:creator>
		<pubDate>Sun, 05 Jul 2009 22:42:31 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/06/20/sql-server-find-length-of-text-field/#comment-53478</guid>
		<description>I am having the same issue as Ramani. Any solution for this ?
I have a text field and what ever number of characters that  I save on that field, it returns only 1001 characters.  But when I checked with DATALENGTH() function it shows that it is having the same number of characters that I entered.</description>
		<content:encoded><![CDATA[<p>I am having the same issue as Ramani. Any solution for this ?<br />
I have a text field and what ever number of characters that  I save on that field, it returns only 1001 characters.  But when I checked with DATALENGTH() function it shows that it is having the same number of characters that I entered.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ramani Sandeep</title>
		<link>http://blog.sqlauthority.com/2007/06/20/sql-server-find-length-of-text-field/#comment-51044</link>
		<dc:creator>Ramani Sandeep</dc:creator>
		<pubDate>Thu, 16 Apr 2009 15:29:33 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/06/20/sql-server-find-length-of-text-field/#comment-51044</guid>
		<description>i want to store more than 8000 chars in table field..
i hv used varchar(max) , text(max) ,but i m not able to get success in it..

everytime data gets truncated whn i insert it..

so can u tell me how to overcome from this problem..?</description>
		<content:encoded><![CDATA[<p>i want to store more than 8000 chars in table field..<br />
i hv used varchar(max) , text(max) ,but i m not able to get success in it..</p>
<p>everytime data gets truncated whn i insert it..</p>
<p>so can u tell me how to overcome from this problem..?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dickson</title>
		<link>http://blog.sqlauthority.com/2007/06/20/sql-server-find-length-of-text-field/#comment-49269</link>
		<dc:creator>Dickson</dc:creator>
		<pubDate>Tue, 17 Mar 2009 07:32:33 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/06/20/sql-server-find-length-of-text-field/#comment-49269</guid>
		<description>Really useful...</description>
		<content:encoded><![CDATA[<p>Really useful&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Andrey</title>
		<link>http://blog.sqlauthority.com/2007/06/20/sql-server-find-length-of-text-field/#comment-46914</link>
		<dc:creator>Andrey</dc:creator>
		<pubDate>Thu, 19 Feb 2009 12:41:43 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/06/20/sql-server-find-length-of-text-field/#comment-46914</guid>
		<description>Thanks. Short and usefull info.</description>
		<content:encoded><![CDATA[<p>Thanks. Short and usefull info.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
