儲存過程 建立全域性臨時表
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE CreateTempTableForPostIdWithIdentity
-- Add the parameters for the stored procedure here
@StartWith int
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
--Create Temp Table
IF Object_id('Tempdb..##PostIdWithIdentity') IS NOT NULL
DROP TABLE ##PostIdWithIdentity
CREATE TABLE ##PostIdWithIdentity
(
ID int IDENTITY (1,1) not null,
PostId nvarchar(255),
Tags nvarchar(MAX),
primary key (ID)
)
truncate table ##PostIdWithIdentity
insert into ##PostIdWithIdentity(PostId,Tags) select Id,Tags from [InstagramData].[dbo].[Post]
Select Top(10)* from ##PostIdWithIdentity
-- Insert statements for procedure here
--SELECT row_number() over (order by Id asc) as id,Id as PostId,Tags From [InstagramData].[dbo].[Post]
END
GO