Here is the use of temporary table inside a stored procedure:
create procedure [dbo].[usp_CreatingTemporaryTable]
as
begin
--creating temporary table here
create table #temp
(
name varchar(50),
address varchar(150)
)
--select * from yourtablename
insert into #temp select column1, column2 from yourtablename
select distinct column1 from #temp
select * from #temp
end
--Finally drop temporary table
drop table #temp
create procedure [dbo].[usp_CreatingTemporaryTable]
as
begin
--creating temporary table here
create table #temp
(
name varchar(50),
address varchar(150)
)
--select * from yourtablename
insert into #temp select column1, column2 from yourtablename
select distinct column1 from #temp
select * from #temp
end
--Finally drop temporary table
drop table #temp
No comments:
Post a Comment