Using Select Command In cursor on TempTable in a Trigger

G

Guest

Hi

I have a trigger which uses temp table using # and inserts some data
selecting from other tables .

After insertion I want to make some calculations in an order of datetime. SO
I use Cursor to select each row and perform some calcutations and insert back
to temp table #.


After insertion I use some validations.

No issues so for. To My surpirse I read in Books Online SQL that we can use
select statement on Temp Tables in a trigger.

Will I have any future problems

Thanks in advance

R.D
 
S

Steve Jorgensen

Hi

I have a trigger which uses temp table using # and inserts some data
selecting from other tables .

After insertion I want to make some calculations in an order of datetime. SO
I use Cursor to select each row and perform some calcutations and insert back
to temp table #.


After insertion I use some validations.

No issues so for. To My surpirse I read in Books Online SQL that we can use
select statement on Temp Tables in a trigger.

Will I have any future problems

Only this - make sure that any table you insert into doesn't have an IDENTITY
column if it will fire on insert via an ADO recordset with a client-side
cursor (requried for an ADP editabe form) or via a DAO recordset. In both of
these cases, the driver will think the @@IDENTITY value produced by the
trigger action belongs to the new record in the table it was trying to insert
into, and it will think the new record could not be found.
 
G

Guest

Hi Steve

I think i did not make it clear. I used T_SQL cursor in a trigger.


Trigger fires and inserts data into temptable. The calculations are done in
that temp table by using cursor and the calculated values are inserted back
to temp table in that cursor.

In the books online it is given that we CANT select records from temptable
in using cursor . is IT SO. but it is working fine for me.

all tables have identity columns and defaults are inserted implicitly

any help

R.D
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top