Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- CREATE PROCEDURE [dbo].[LIST_CLIENTS]
- CREATE TABLE #CLIENT(
- --Varchar And Numeric Values goes here
- )
- /*Several Select's and Insert's against the Temporary Table*/
- SELECT * FROM #CLIENT
- END
- sp_configure 'Show Advanced Options', 1
- GO
- RECONFIGURE
- GO
- sp_configure 'Ad Hoc Distributed Queries', 1
- GO
- RECONFIGURE
- GO
- SELECT *
- INTO #CLIENT
- FROM OPENROWSET
- ('SQLOLEDB','Server=(local);Uid=Cnx;pwd=Cnx;database=r8;Trusted_Connection=yes;
- Integrated Security=SSPI',
- 'EXEC dbo.LIST_CLIENTS ''20110602'', NULL, NULL, NULL, NULL, NULL')
- Msg 208, Level 16, State 1, Procedure LIST_CLIENTS, Line 43
- Invalid object name '#CLIENT'.
- USE tempdb;
- GO
- CREATE PROCEDURE dbo.proc_x
- AS
- BEGIN
- SET NOCOUNT ON;
- DECLARE @x TABLE(id INT);
- INSERT @x VALUES(1),(2);
- SELECT * FROM @x;
- END
- GO
- SELECT *
- INTO #client
- FROM OPENQUERY
- (
- [loopback linked server name],
- 'EXEC tempdb.dbo.proc_x'
- ) AS y;
- SELECT * FROM #client;
- DROP TABLE #client;
- DROP PROCEDURE dbo.proc_x;
- IF OBJECT_ID('dbo.temptable', 'U') IS NOT NULL
- BEGIN
- DROP TABLE dbo.temptable
- END
- CREATE TABLE dbo.temptable
- ( ... )
- declare @t table(ID int, Name varchar(15));
- if (0 = 1) select ID, Name from @t; -- fake SELECT statement
- create table #T (ID int, Name varchar(15));
- select ID, Name from #T; -- real SELECT statement
- declare @fmtonlyOn bit = 0;
- if 1 = 0 set @fmtonlyOn = 1;
- set fmtonly off;
- create table #T (ID int, Name varchar(15));
- if @fmtonlyOn = 1 set fmtonly on;
- select ID, Name from #T;
Add Comment
Please, Sign In to add comment