CREATE PROCEDURE OrDerBack
@WorkTableName char(30),
@TableName char(30),
@KeyName char(20),
@KeyNumber Char(20) ,
@mWorkFlowName char(20),
@mPerID char(20)
AS
set nocount on
declare @ChvSQl char(255)
declare @TempSQL char(255)
--这里先建好临时表。
select @ChvSQl=' select * into #temp from '+ @WorkTableName +'where '+@KeyName+'='+@KeyNumber+' and If_Access=1 order by WorkFlowCount'
exec(@ChvSQl)
select * from #Temp
@WorkTableName char(30),
@TableName char(30),
@KeyName char(20),
@KeyNumber Char(20) ,
@mWorkFlowName char(20),
@mPerID char(20)
AS
set nocount on
declare @ChvSQl char(255)
declare @TempSQL char(255)
--这里先建好临时表。
select @ChvSQl=' select * into #temp from '+ @WorkTableName +'where '+@KeyName+'='+@KeyNumber+' and If_Access=1 order by WorkFlowCount'
exec(@ChvSQl)
select * from #Temp
set nocount on
select parentsid,nowid into #temp1 from bomdetail where nowid=@ParentID
select * from #temp1
正确,主要临时表生存期问题
if (1=2)
{
int i;
i=1;
}
print i;
==========================
你要不就用全局##
要不就:
int i;
if (1=2)
{
i=1;
}
print i;相信你看得懂!
if object_id('tempdb..##temp') is not null
drop table ##temp
...........
@WorkTableName char(30),
@TableName char(30),
@KeyName char(20),
@KeyNumber Char(20) ,
@mWorkFlowName char(20),
@mPerID char(20)
AS
set nocount on
declare @ChvSQl char(255)
declare @TempSQL char(255)
--这里先建好临时表。
select @ChvSQl=' select * into #temp from '+ @WorkTableName +'where '+@KeyName+'='+@KeyNumber+' and If_Access=1 order by WorkFlowCount
select * from #Temp'
exec(@ChvSQl)
这样可以的,我现在都这样处理