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 |
|
DoPLeGaNgA
Starting Member
1 Post |
Posted - 2004-03-11 : 15:54:28
|
| Hi!How can I set a character limit to return values <=60 in a where clause. I'm selecting a field from a table using a where clause that returns field values that are not null, but I also want to limit results to values that are less than 60 characters in legnth. Below is what I have so far. I've tried a few things but I think I may be using the incorrect syntax. I can get the results excluding the null values with the query but I can't seem to figure out how to also exclude values greater than 60 characters. Any help would be greatly appreciated. Thank you!select NEWVALUEfrom AUDITLOG_FIELDLEVELwhere NEWVALUE is not null |
|
|
Frank Kalis
Constraint Violating Yak Guru
413 Posts |
Posted - 2004-03-11 : 16:07:28
|
| [code]AND DATALENGTH(NEWVALUE)<=60[/code]--Frankhttp://www.insidesql.deSorry, for editing, but depending on your datatype for that column NEWVALUE you might need to multiply times 2 when the datatype is a unicode datatype. |
 |
|
|
X002548
Not Just a Number
15586 Posts |
Posted - 2004-03-11 : 16:31:57
|
| I'm not so sure s/he is looking for storage....[CODE]USE NorthwindGOCREATE TABLE myTable99(Col1 char(10), Col2 varchar(10), Col3 nvarchar(10))GOINSERT INTO myTable99(Col1, Col2, Col3)SELECT '12345', '12345', '12345'GOSELECT LEN(Col1),LEN(Col2),LEN(Col3) FROM myTable99SELECT DATALENGTH(Col1),DATALENGTH(Col2),DATALENGTH(Col3) FROM myTable99GODROP Table myTable99GO[/CODE]Brett8-) |
 |
|
|
Frank Kalis
Constraint Violating Yak Guru
413 Posts |
Posted - 2004-03-12 : 03:01:38
|
Who knows? However, the original questioner should now have some ideas for a solution, right? --Frankhttp://www.insidesql.de |
 |
|
|
|
|
|
|
|