Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.

Kako napraviti temp tabelu "vidljivu" u dve stored procedure?

[es] :: MS SQL :: Kako napraviti temp tabelu "vidljivu" u dve stored procedure?

[ Pregleda: 4079 | Odgovora: 5 ] > FB > Twit

Postavi temu Odgovori

Autor

Pretraga teme: Traži
Markiranje Štampanje RSS

vujkev
Beograd

Član broj: 8072
Poruke: 1347
212.200.243.*



+104 Profil

icon Kako napraviti temp tabelu "vidljivu" u dve stored procedure?25.08.2007. u 20:16 - pre 202 meseci
Da li postoji opcija da se kreira #temp tabela koja ce "ziveti" tokom cele konekcije ka bazi. Poenta je da rezultat jedne stored procedure (SP vraća tabelu) moram dodatno da obradim pre nego što pozovem drugu SP koja će koristiti tu tabelu.
Naučio sam...
Da je važnije biti ljubazan nego biti u pravu
 
Odgovor na temu

goranvuc
Goran Vucicevic
Novi Sad

Član broj: 4934
Poruke: 1846
*.dialup.neobee.net.



+41 Profil

icon Re: Kako napraviti temp tabelu "vidljivu" u dve stored procedure?25.08.2007. u 20:29 - pre 202 meseci
Citat:

You can create local and global temporary tables. Local temporary tables are visible only in the current session; global temporary tables are visible to all sessions.

Prefix local temporary table names with single number sign (#table_name), and prefix global temporary table names with a double number sign (##table_name).

SQL statements reference the temporary table using the value specified for table_name in the CREATE TABLE statement:

CREATE TABLE #MyTempTable (cola INT PRIMARY KEY)
INSERT INTO #MyTempTable VALUES (1)

If a local temporary table is created in a stored procedure or application that can be executed at the same time by several users, SQL Server has to be able to distinguish the tables created by the different users. SQL Server does this by internally appending a numeric suffix to each local temporary table name. The full name of a temporary table as stored in the sysobjects table in tempdb consists of table name specified in the CREATE TABLE statement and the system-generated numeric suffix. To allow for the suffix, table_name specified for a local temporary name cannot exceed 116 characters.

Temporary tables are automatically dropped when they go out of scope, unless explicitly dropped using DROP TABLE:

A local temporary table created in a stored procedure is dropped automatically when the stored procedure completes. The table can be referenced by any nested stored procedures executed by the stored procedure that created the table. The table cannot be referenced by the process which called the stored procedure that created the table.


All other local temporary tables are dropped automatically at the end of the current session.


Global temporary tables are automatically dropped when the session that created the table ends and all other tasks have stopped referencing them. The association between a task and a table is maintained only for the life of a single Transact-SQL statement. This means that a global temporary table is dropped at the completion of the last Transact-SQL statement that was actively referencing the table when the creating session ended.
A local temporary table created within a stored procedure or trigger is distinct from a temporary table with the same name created before the stored procedure or trigger is called. If a query references a temporary table, and two temporary tables with the same name exist at that time, it is not defined which table the query is resolved against. Nested stored procedures can also create temporary tables with the same name as a temporary table created by the stored procedure that called it.
 
Odgovor na temu

vujkev
Beograd

Član broj: 8072
Poruke: 1347
212.200.243.*



+104 Profil

icon Re: Kako napraviti temp tabelu "vidljivu" u dve stored procedure?26.08.2007. u 12:54 - pre 202 meseci
Hmmmm neko se gadno igra samnom. Našao sam sličan tekst na netu pre nego što sam postavio ovo pitanje i naravno probao to rešenje koje tad nije radilo.

Sada sam opet probao isto to i sad radi :S


U svakom slučaju hvala
Naučio sam...
Da je važnije biti ljubazan nego biti u pravu
 
Odgovor na temu

ivan jeremic
Bgd

Član broj: 51138
Poruke: 48
*.procreditbank.co.yu.



Profil

icon Re: Kako napraviti temp tabelu "vidljivu" u dve stored procedure?28.08.2007. u 09:16 - pre 202 meseci
CREATE TABLE ##t (kolona1 int, kolona2 nvarchar(255))

Sa dve tarabe ti se pravi globalna privremena tabela koja zivi dokle god je konekcija ziva.

 
Odgovor na temu

M E N E
borislav
Temerin

Član broj: 30434
Poruke: 231
*.nspoint.net.



+1 Profil

icon Re: Kako napraviti temp tabelu "vidljivu" u dve stored procedure?29.02.2008. u 12:35 - pre 196 meseci
@vujkev
da, i ja sam probao sa 2x# i ne radi... hm...
Ko god se igra sa tobom, igra se i sa mnom
Uhvatili ste me nespremnog
 
Odgovor na temu

Koce
DBA
Serbia, Belgrade

Član broj: 59217
Poruke: 144
*.vektor.net.



+1 Profil

icon Re: Kako napraviti temp tabelu "vidljivu" u dve stored procedure?04.03.2008. u 07:51 - pre 196 meseci
tabela sa ## ce se vidjeti ako ti je tekuca sesija "alive", npr iz QA u jednoj sp mozes da je kreiras a u drugoj da je koristis....
 
Odgovor na temu

[es] :: MS SQL :: Kako napraviti temp tabelu "vidljivu" u dve stored procedure?

[ Pregleda: 4079 | Odgovora: 5 ] > FB > Twit

Postavi temu Odgovori

Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.