// Trying to update DynamicPageContent.Html where DynamicPageContent.PageID='121'
//With
// Select Html from DynamicPageHistory where HistoryID='831'
//
Update DynamicPageContent
SET Html=(SELECT Html FROM DynamicPageHistory WHERE HistoryID='831')
WHERE PageID='121'
With the following error:
Server: Msg 279, Level 16, State 3, Line 1
The text, ntext, and image data types are invalid in this subquery or aggregate expression.
DynamicPageContent.Html is Ntext size 16 and DynamicPageHistory.Html is Ntext size 16. PageID is and int and HistoryID is an int. It fails with single quotes around 831 and 121 and it fails without single quotes. The error message is the same both ways.
Ideas?
Thanks,
Rex
Look at the error message, it indicates the HTML column (whose data type is NTEXT) can not be used in subquery. To manipulate BLOB data, you should use some system functions. You can start from here:
http://msdn.microsoft.com/library/en-us/acdata/ac_8_con_11_7zox.asp?frame=true
|||I'm not a DBA at all and the SQL syntax is weird for me in terms of ordering the operations how would I modify the above SQL to use a declared variable and insert that value? Sorry to be so simple minded on this I'm learning as I go...|||Nevermind:) Well, you can use something like this:
DECLARE @.val_His varbinary(16)
SELECT @.val_His = textptr(Html) FROM DynamicPageContent
WHERE HistoryID='831'
DECLARE @.val_Content varbinary(16)
SELECT @.val_Content = textptr(Html) FROM DynamicPageContent
WHERE PageID='121'
WRITETEXT DynamicPageContent.Html @.val_His @.val_Content
|||After posting to you I just plain wrote the SQL Select in ASP stuffed it into a string passed it as a param to the Update and let ASP do all the thinking.Snap-Snap-Done. :)
Thank you for the help though.
No comments:
Post a Comment