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.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 ntext question

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2005-12-19 : 09:12:24
writes "Here is my problem - I am trying to update a ntext column of a table based on whether the serial no from that table belongs to the serial no from one/both of the other two tables.
when i try to update just base d on one table it works fine. But when i try to update based on two tables using an if statement it says the table name used as a column prefix does not match.

BEGIN

DECLARE @ptrval varbinary(16)
DECLARE @id int

DECLARE curs cursor local forward_only
for
SELECT TEXTPTR(LOG_HEAD_1.Notes), LOG_HEAD_1.[ID] FROM LOG_HEAD_1 WHERE (LOG_HEAD_1.SN_ref IN (select SerialNumber from C400Upload)


AND LOG_HEAD_1.Notes NOT LIKE ' ')OR (LOG_HEAD_1.SN_ref IN (select SerialNumber from RecallUpload)AND LOG_HEAD_1.Notes NOT LIKE ' ')


open curs
begin

fetch next from curs into @ptrval, @id

while @@fetch_status = 0

IF(LOG_HEAD_1.[SN_ref] IN (select SerialNumber from C400Upload))
UPDATETEXT LOG_HEAD_1.Notes @ptrval 0 0 'C400 needs upgrade, per SB 09/05. Send PN 1820511 (no charge) and notify QA.'
IF(LOG_HEAD_1.[SN_ref] IN (select SerialNumber from RecallUpload))
UPDATETEXT LOG_HEAD_1.Notes @ptrval 0 0 'Recall reported NOT DONE. Arrange for parts to be sent. See QA for specifics. Send Log Entry to QA or David Miller.'

fetch next from curs into @ptrval, @id

end
close curs
deallocate curs
END


error message
Server: Msg 107, Level 16, State 1, Line 23
The column prefix 'LOG_HEAD_1' does not match with a table name or alias name used in the query.
The column prefix 'LOG_HEAD_1' does not match with a table name or alias name used in the query."

Srinika
Master Smack Fu Yak Hacker

1378 Posts

Posted - 2005-12-19 : 10:28:07
Check this as follows:

IF(LOG_HEAD_1.[SN_ref] IN (select SerialNumber from C400Upload))
print 'AAAA'

If it works the prob is in UpdateText ....
Else problem is in If ....

I assume the problem is in If ....

Change the If statement as follows and c:
IF exists (Select * from LOG_HEAD_1 where [SN_ref] IN (select SerialNumber from C400Upload))
Print 'BBBB'
Go to Top of Page
   

- Advertisement -