vBulletin Search Engine Optimization
| |||||||
| Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| Hello all, I want to know if it's possible to make a select statement that brings only the records with a number of bytes of less than 8060 so, imagine I have a table with 10 records, and two of those ten records have more than 8060 bytes, so, if I do this: select a, b, c, d from tableX where (len(a)+len(b)+len(c)+len(d) < 8060) it will only bring 8 records, not 10 I tried this approach and it doesn't work, so, my question is, is there a way (similar to this) using a select statement to limit the results to those records with less than 8060 bytes, so I will never get the error? Thanks again for all your help!, SB-R |
| |||
| BTW, I'm using SQL Server 2000 Thanks again... "segis bata" <segisbata@hotmail.com> wrote in message news:%23wY31UQdIHA.4744@TK2MSFTNGP06.phx.gbl... > Hello all, > > I want to know if it's possible to make a select statement that brings > only the records with a number of bytes of less than 8060 > > so, imagine I have a table with 10 records, and two of those ten records > have more than 8060 bytes, so, if I do this: > > select a, b, c, d from tableX > where (len(a)+len(b)+len(c)+len(d) < 8060) > > it will only bring 8 records, not 10 > > I tried this approach and it doesn't work, so, my question is, is there a > way (similar to this) using a select statement to limit the results to > those records with less than 8060 bytes, so I will never get the error? > > Thanks again for all your help!, > SB-R |
| |||
| On Feb 22, 8:43*am, "segis bata" <segisb...@hotmail.com> wrote: > BTW, I'm using SQL Server 2000 > > Thanks again... > > "segis bata" <segisb...@hotmail.com> wrote in message > > news:%23wY31UQdIHA.4744@TK2MSFTNGP06.phx.gbl... > > > > > Hello all, > > > I want to know if it's possible to make a select statement that brings > > only the records with a number of bytes of less than 8060 > > > so, imagine I have a table with 10 records, and two of those ten records > > have more than 8060 bytes, so, if I do this: > > > select a, b, c, d from tableX > > where (len(a)+len(b)+len(c)+len(d) < 8060) > > > it will only bring 8 records, not 10 > > > I tried this approach and it doesn't work, so, my question is, is there a > > way (similar to this) using a select statement to limit the results to > > those records with less than 8060 bytes, so I will never get the error? > > > Thanks again for all your help!, > > SB-R- Hide quoted text - > > - Show quoted text - Dear Segis, It is not possible to trim the record size using a where predicate. If you are using table which has record length more than 8060 bytes then it should be having varchar column. If so...on the varchar column use substring function to trim the data above 8060 bytes. Hope this suggestion helps. Regards Balaji |
| ||||
| The LEN() function returns the number of characters, not the number of bytes. DATALENGTH() returns the number of bytes. If you have any NVARCHAR columns, which use two bytes per character, you need to use DATALENGTH(). Also note that there is overhead to the row that is not captured with the expression you have. Part of that is two bytes for each varying length column. Roy Harvey Beacon Falls, CT On Thu, 21 Feb 2008 22:43:49 -0500, "segis bata" <segisbata@hotmail.com> wrote: >BTW, I'm using SQL Server 2000 > >Thanks again... > > >"segis bata" <segisbata@hotmail.com> wrote in message >news:%23wY31UQdIHA.4744@TK2MSFTNGP06.phx.gbl... >> Hello all, >> >> I want to know if it's possible to make a select statement that brings >> only the records with a number of bytes of less than 8060 >> >> so, imagine I have a table with 10 records, and two of those ten records >> have more than 8060 bytes, so, if I do this: >> >> select a, b, c, d from tableX >> where (len(a)+len(b)+len(c)+len(d) < 8060) >> >> it will only bring 8 records, not 10 >> >> I tried this approach and it doesn't work, so, my question is, is there a >> way (similar to this) using a select statement to limit the results to >> those records with less than 8060 bytes, so I will never get the error? >> >> Thanks again for all your help!, >> SB-R > |