January 30, 2003 at 7:18 pm
I have an insert statement and have a need to use a local varible like so ins.@myvariable). Is there a way in T-SQL to do this. Below is the complete statement taken from an insert trigger. (ins.@cname is the problem)
example:
insert into auditHistory
(auditOrgId, auditPropID, auditTableName, auditTableColumn, auditColumnType, auditAction, auditData)
select 'IGT', 'IGT', 'ImageTypes', @cName, @cType, 'I', ins.@cName
from inserted ins
February 3, 2003 at 12:00 pm
This was removed by the editor as SPAM
February 3, 2003 at 12:54 pm
Not sure exactly what you need. You can use local variables, but because the trigger is a set operation and not a single row, you have to code so that variable is meaningful. In any case you'd just refer to @Variable without a reference to the logical inserted or deleted tables.
Andy
February 4, 2003 at 3:30 am
Actually I have never heard of a variable referenced like so. A variable is a logically defined struture that lives only in the current context. If you made a column name in a table with @xxx you could try wrapping with []. How exactly does "ins." fit into this?
February 4, 2003 at 10:42 am
I also have never seen a varible used in this context. Basicaly I have a cursor that will go through each column and do an insert into an audit table for each column in the table. Instead of needing to spell out the insert in the traditional manner (ins.columnName), I was wondering if there was a way to use the varible, like (ins.[@varcolumn]. The @varColumn would actually contain the column name.
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply