July 11, 2003 at 9:46 am
Is there a restriction on how you use Input Parameters? The following code tells me I have to declare the input variables...
alter proc lp_releasehold
(
@holdname varchar(255),
@loadname varchar(255)
)
as
select * into #temphold from @holdname where release = 1
alter table #temphold drop column sbcid
insert into @loadname select * from #temphold
--delete from @holdname where release = 1
July 14, 2003 at 5:42 am
quote:
Is there a restriction on how you use Input Parameters? The following code tells me I have to declare the input variables...alter proc lp_releasehold
(
@holdname varchar(255),
@loadname varchar(255)
)
as
select * into #temphold from @holdname where release = 1
alter table #temphold drop column sbcid
insert into @loadname select * from #temphold
--delete from @holdname where release = 1
What you are trying to do is called double evaluation and unfortunately SQL Server doesn't handle that. It means that you can't use variables' value as identifier in T-SQL. The only way is to buld and run a dynamic SQL using EXECUTE().
July 14, 2003 at 5:53 am
Or sp_executesql, which has the advantage of reusing query plans.
Andy
Viewing 5 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply