Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
johnstern
Yak Posting Veteran
67 Posts |
Posted - 2007-05-09 : 14:57:12
|
| I am trying to get all the records where a particular field ( description) has no more that two characterssomething like thisselect * from mytable where description.lenght < 3 |
|
|
harsh_athalye
Master Smack Fu Yak Hacker
5581 Posts |
Posted - 2007-05-09 : 14:59:26
|
| [code]SELECT * from Table where datalength(Description) <= 2[/code]Harsh AthalyeIndia."The IMPOSSIBLE is often UNTRIED" |
 |
|
|
Lamprey
Master Smack Fu Yak Hacker
4614 Posts |
Posted - 2007-05-09 : 15:57:49
|
Depending on the datatype, you will want to use LEN or DATALENGTH as they will return different values. If you have AdventureWorks installed you can use this query or modify it to run against your database:USE AdventureWorks;GOSELECT LEN(Name) AS Length, DATALENGTH(Name) AS DataLen, NameFROM Production.ProductORDER BY Name;GO EDIT: For got to mention that your Compatability Level may affect the results as well. See sp_dbcmptlevel in BOL. |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2007-05-10 : 06:17:27
|
quote: select * from mytable where description.lenght < 3
Thats front end code MadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|