Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


How to retrieve Table Variable data in a Trigger


How to retrieve Table Variable data in a Trigger

Author
Message
Minnu
Minnu
Old Hand
Old Hand (305 reputation)Old Hand (305 reputation)Old Hand (305 reputation)Old Hand (305 reputation)Old Hand (305 reputation)Old Hand (305 reputation)Old Hand (305 reputation)Old Hand (305 reputation)

Group: General Forum Members
Points: 305 Visits: 950
Hi SSC Team,


i have created a stored procedure with a "table variable" in it,
inserted some records into table variable based on some conditions.


and my requirement is :
i have another trigger, i want to use the data available in table variable

How it is possible.

Please Help
bugg
bugg
Old Hand
Old Hand (303 reputation)Old Hand (303 reputation)Old Hand (303 reputation)Old Hand (303 reputation)Old Hand (303 reputation)Old Hand (303 reputation)Old Hand (303 reputation)Old Hand (303 reputation)

Group: General Forum Members
Points: 303 Visits: 967
Minnu (12/4/2012)
Hi SSC Team,


i have created a stored procedure with a "table variable" in it,
inserted some records into table variable based on some conditions.


and my requirement is :
i have another trigger, i want to use the data available in table variable

How it is possible.

Please Help


A table @variable will only hold is value for the session its in.

Rather create a #temp table which you can use in your other 'trigger' then drop it after you have finished with it.
Minnu
Minnu
Old Hand
Old Hand (305 reputation)Old Hand (305 reputation)Old Hand (305 reputation)Old Hand (305 reputation)Old Hand (305 reputation)Old Hand (305 reputation)Old Hand (305 reputation)Old Hand (305 reputation)

Group: General Forum Members
Points: 305 Visits: 950
using a stored procedure inserted records in to a #Temp_Table.

how to retieve the data in a Trigger

am using below

#Temp_Table
----------------------
Id | Name
----------------------
101 Paint
102 Walls
103 Furn
----------------------


Trigger:

Create trigger Trigger_Name
(
---
---
)

EXEC Stored_procedure @ID
select * from #temp_table

--

But it is not working

Syntax..Or query...
.Plz
bugg
bugg
Old Hand
Old Hand (303 reputation)Old Hand (303 reputation)Old Hand (303 reputation)Old Hand (303 reputation)Old Hand (303 reputation)Old Hand (303 reputation)Old Hand (303 reputation)Old Hand (303 reputation)

Group: General Forum Members
Points: 303 Visits: 967
Don't think you can create a trigger on a temp table:

see this post

http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=96386
Minnu
Minnu
Old Hand
Old Hand (305 reputation)Old Hand (305 reputation)Old Hand (305 reputation)Old Hand (305 reputation)Old Hand (305 reputation)Old Hand (305 reputation)Old Hand (305 reputation)Old Hand (305 reputation)

Group: General Forum Members
Points: 305 Visits: 950
Sorry for asking,

my requirement is:

i've to call the stored procedure based on "id" and get the corresponding Name from the temp table.

Please suggest
Lowell
Lowell
SSChampion
SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)

Group: General Forum Members
Points: 14975 Visits: 38996
Minnu (12/4/2012)
Sorry for asking,

my requirement is:

i've to call the stored procedure based on "id" and get the corresponding Name from the temp table.

Please suggest


wouldn't that be a simple select?
SELECT name from #temp where ID = @param

am i misreading the quesiton, or is there more to it than that?

Lowell

--
help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search