October 9, 2009 at 8:37 am
How to create a Global Temp Table in which the user should be able to select the values inserted by him only
October 9, 2009 at 8:46 am
well first, why a global temp table if you want to select justthe stuff your user inserted? why would a private temp table not do the trick?
but to answer your question, here's how i would do it:
if not exists (select object_id('tempdb..##MyGlobalTemp'))
create table ##MyGlobalTemp(spid int,otherdata varchar(30) )
insert into ##MyGlobalTemp(spid,otherdata)
select @@spid,'stuff'
select * from ##MyGlobalTemp where spid=@@spid
Lowell
October 9, 2009 at 9:18 am
Still the records inserted in User Session 1 is visible in the user Session2, guess, it is the behavior of Global temporary table. I need something similiar to Global Temporary table in Oracle. The Requirement goes like this, the users insert multiple records at runtime, on doing a Select Top 1* , it should retrieve only the respective first record. The table should be physically available. How can I achieve it in MSSQL
October 9, 2009 at 9:50 am
from what i read here:http://www.oracle-base.com/articles/8i/TemporaryTables.php
an oracle global temporary table seems to be the same as a regualr sql temp table...it is created for the user who connected, is not accessible by anyone else, and goes away when the user disconnects. it seems that oracle just makes one table for multiple session to use, but still filters by session id.
that is different than a SQL global temp table, which exists for multiple sessions to access, but each session has access to all the data in the table.
since it sounds like your user needs to insert some adta, and then select one row based on some criteria, and also not mix it with other users data, you need just a simply temp table:
create table #mytemp...
Lowell
Viewing 4 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply