Drop Table

Support Forum for database administrators and web based access to important newsgroups related to databases
Register on Database Support Forum Edit your profileCalendarFind other Database Support forum membersFrequently Asked QuestionsSearch this forum -> 
For Database admins: Free Database-related Magazines Now Free shipping to Texas


Post New Thread










Thread
Author

how many char's in varchar record
hello

How could I check how many chars are in record, defined as varchar(8000).
It's obvious that in such defined record could be 1 char to 8000 char. But
what query to SQL database should I post to give information about realy
lenght of this records ?

thanks from advance

Adam


Report this thread to moderator Post Follow-up to this message
Old Post
adam
08-22-05 12:24 PM


Re: how many char's in varchar record
See LEN() and "String Functions" in Books Online.

Simon


Report this thread to moderator Post Follow-up to this message
Old Post
Simon Hayes
08-22-05 12:24 PM


Re: how many char's in varchar record
Select len(field)
or
Select DataLength(field)

Madhivanan


Report this thread to moderator Post Follow-up to this message
Old Post
Madhivanan
08-22-05 02:23 PM


Re: how many char's in varchar record
Be careful - the two functions are not the same. LEN() returns the
number of characters after removing trailing blanks, but DATALENGTH()
returns the number of bytes stored. So you can get different results if
trailing blanks are present, if you have varchar vs char, or if you use
Unicode columns - see the code below, and Books Online for more
details.

Simon

create table #t (v varchar(10), nv nvarchar(10))

insert into #t select 'X', 'X'
insert into #t select 'X  ', 'X  '  -- two trailing blanks

select len(v), datalength(v), len(nv), datalength(nv)
from #t

create table #t1 (c char(10), nc nchar(10))

insert into #t1 select 'X', 'X'
insert into #t1 select 'X  ', 'X  '  -- two trailing blanks

select len(c), datalength(c), len(nc), datalength(nc)
from #t1


Report this thread to moderator Post Follow-up to this message
Old Post
Simon Hayes
08-22-05 02:23 PM


Re: how many char's in varchar record
Thanks Simon

Madhivanan


Report this thread to moderator Post Follow-up to this message
Old Post
Madhivanan
08-22-05 02:23 PM


Re: how many char's in varchar record
thanx for all for valuable information!

best wishes
Adam


Report this thread to moderator Post Follow-up to this message
Old Post
adam
08-23-05 01:23 AM


Sponsored Links





Last Thread Next Thread
Post New Thread

Microsoft SQL Server forum archive

Show a Printable Version Email This Page to Someone! Receive updates to this thread
Microsoft SQL Server
Access database support
PostgreSQL Replication
SQL Server ODBC
FoxPro Support
PostgreSQL pgAdmin
SQL Server Clustering
MySQL ODBC
Web Applications with dBASE
SQL Server CE
MySQL++
Sybase Database Support
MS SQL Full Text Search
PostgreSQL Administration
SQL Anywhere support
DB2 UDB Database
Paradox Database Support
Filemaker Database
Berkley DB
SQL 2000/2000i database
ASE Database
Forum Jump:
All times are GMT. The time now is 12:02 PM.

 
Mobile devices forum | Database support forum archive




Copyrights DropTable.com Database Support Forum 2004 - 2006