Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can anyone point me in the right di

Status
Not open for further replies.

MrWilly

MIS
Nov 9, 2001
36
US
Can anyone point me in the right direction here...

I'm looking to write a query to return a list of values that meet a certain condition... I thought it would be pretty simple...I'm stuck.

The query should only return those values which are over a certain length (say 16 characters)...

select [column] from [tablename]where ?????

Thanks in advance...
 
Never mind.... I figured it out.

--This will show that you currently have x # of records where [column] length is greater than 16 characters

select count(*) from [tablename] where datalength [(column)] > 16

 
This gives you the number of bytes not the number of characters which is fine if you are using varchar datatype, but would not work correctly for nvarchar because each character takes 2 bytes in nvarchar. If you want the actual character numbers use len() instead.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top