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 |
Stumbler
Starting Member
23 Posts |
Posted - 2007-09-21 : 06:26:03
|
I'm sure it is possible to select all records where the length of a given field equals a certain value, but I don't know how to do it?Can somebody tell me how?Hans |
|
harsh_athalye
Master Smack Fu Yak Hacker
5581 Posts |
Posted - 2007-09-21 : 06:32:10
|
[code]Select * from table where datalength(field1) = 5[/code]If it is CHAR field, trimming the field may be necessary.Harsh AthalyeIndia."The IMPOSSIBLE is often UNTRIED" |
|
|
jimf
Master Smack Fu Yak Hacker
2875 Posts |
Posted - 2007-09-21 : 06:44:44
|
You may also want select * frim where LEN(field1) = 5Look up BOL for the difference between DATALENGTH AND LENselect datalength(12356789) = 4select len('123456789') = 9Jim |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2007-09-21 : 06:53:29
|
Also note that any use of function over indexed column will force SCAN than SEEKMadhivananFailing to plan is Planning to fail |
|
|
Stumbler
Starting Member
23 Posts |
Posted - 2007-09-21 : 07:06:55
|
Thanks to you all for taking the time to answer my questionHans |
|
|
|
|
|