April 11, 2005 at 3:17 pm
Hi,
I have a strange error in one of the query that I am doing. And, I am un-sure on how to resolve it. Here is the query :
FROM
syscomments c
INNER JOIN sysobjects o ON c.id = o.id
WHERE
(o.xtype = 'P') AND (
(c.text LIKE '%a%')
OR
(o.name like '%a%')
 
ORDER BY
o.name,
c.number,
c.colid
April 11, 2005 at 4:58 pm
(From what I know...)
Yes it includes the text (varchar) column. (even though you think it's 4k because of nvarchar it may be 2 bytes per position).
So, in order to do the order by it needs to move the data to a temp table and that's where it wants to choke. It may happen to work if you have an index that supports the order and filter (order by & where clauses).
The other way I've hacked around this is to convert the text column to varchar (from nvarchar) so that max length of all columns is under 8k, or if that fails, make assumptions on the text field that none is bigger than like 3k, and convert that one on select.
(like select a, b, convert(varchar(4000), t) from...)
April 12, 2005 at 7:10 am
name is sysname(128) = 128
number and colid are smallint = 4
Text is nvarchar(4000) = 8000
So you can definitly bust the 8094 limit there. But as John suggested, you can convert the text to varchar (unless you use chinese text in there) and it'll go down 4000 characters.
April 12, 2005 at 9:02 am
Done, and it worked.
Thanks to both of you guys.
January 23, 2007 at 10:10 am
John,
Thanks for your solutions. I tried changed all my nvarchar to varch and the problem went away. Thanks a bunch.
Dom
January 23, 2007 at 4:56 pm
I stand corrected. Sysname is Nvarchar(128)... Just in case anyone reads this later on.
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply