Friday, March 9, 2012

error Multi-part identifier

After OK parse, I try to execute this statement in a trigger:
if inserted.col1 = 10 --col1 type int
--do instruction
But I have this message:
The multi-part identifier "inserted.col1" could not be bound.
What is this problem'
How can I resolve it?
Thanks!
Good night!Inserted is a "table" that can have many rows in it (1 for each row inserted
or updated in the statement that fired the trigger). As such, you could do
something like this:
SELECT @.variable = col1 FROM Inserted
IF @.Variable = 10 ...
However, this will only get the col1 value from 1 of the rows in the
inserted table.
Show us the rest of the code in your trigger and we can likely help you
write it using a set based solution that will handle multiple rows in the
inserted table.
"bubixx" <bubixx@.discussions.microsoft.com> wrote in message
news:7BBC3219-4A58-4561-8DBA-95CF54E46489@.microsoft.com...
> After OK parse, I try to execute this statement in a trigger:
> if inserted.col1 = 10 --col1 type int
> --do instruction
> But I have this message:
> The multi-part identifier "inserted.col1" could not be bound.
> What is this problem'
> How can I resolve it?
> Thanks!
> Good night!|||You can't do a direct comparison on a column in a table in an IF statement.
It's pretty tough to tell you what the appropriate syntax should be without
knowing more about what you are trying to do. In any case you should always
code triggers to account for multiple rows being affected. What you are
trying to do infers only one row is ever affected which will ultimately get
you in trouble.
Andrew J. Kelly SQL MVP
"bubixx" <bubixx@.discussions.microsoft.com> wrote in message
news:7BBC3219-4A58-4561-8DBA-95CF54E46489@.microsoft.com...
> After OK parse, I try to execute this statement in a trigger:
> if inserted.col1 = 10 --col1 type int
> --do instruction
> But I have this message:
> The multi-part identifier "inserted.col1" could not be bound.
> What is this problem'
> How can I resolve it?
> Thanks!
> Good night!

No comments:

Post a Comment