The text, ntext, and image data types are invalid in this subquery or aggregate expression
I have a client I was building an e-commerce website for. I was developing the website on MS SQL 2005 Database, but their deployment server have MS SQL 2000. From experience I knew there are some stuffs that would not work in MS SQL 2000, so I avoid them. This one missed my eyes. I get this error message on the search results page:
The text, ntext, and image data types are invalid in this subquery or aggregate expression.
After checking I found I was trying to get a TEXT column in a subquery, and that was causing the problem. An example query is:
Select customerName,customerNote=(select top 1 note from customerNotes Where customerId=C.customerId) from Customers C
Note that the column NOTE is a text column that was causing the problem.
Solution:
The text column need to be retrieved as a varchar column. Rewriting the query this way solves the problemma:
Select customerName,customerNote=(select top 1 Cast(note As varchar(500)) from customerNotes Where customerId=C.customerId) from Customers C
You can also use Convert instead of Cast like this:
Select customerName,customerNote=(select top 1 Convert(varchar(500),note) from customerNotes Where customerId=C.customerId) from Customers C










create procedure createnewleft1copy(@BranchId nvarchar(50))
as
update tblImages set imgleft1old=(select Cast(imgleft1 as image) from tblImages ) where BranchId=@BranchId
GO
iam using sql server 2000
it is giving error
Server: Msg 279, Level 16, State 3, Procedure createnewleft1copy, Line 3
The text, ntext, and image data types are invalid in this subquery or aggregate expression.
can you corect where iam going wrong
@charan
Here is the quote from MS:
Automatic data type conversion is not supported for the text and image data types. You can explicitly convert text data to character data, and image data to binary or varbinary, but the maximum length is 8000.
Also your error message says the problem.
You can try to save the old value on a local variable, then use it to make the update.
Hope that helps.
Leave your response!
Categories
Most Commented
Recent Comments
Blogroll
Most Viewed