declare @tablename set @tablename = '...' exec('select * from '+@tablename +' where ... ') 楼上的,你这个是放在存储过程里面吗??? 我没用过这东西呀。。
就是动态sql的使用 declare @tablename set @tablename = '...' exec('select * from '+@tablename +' where ... ')
string AllSql="declare @tablename @AppID @ContentID"; string AllSql=AllSql+"set @tablename = 'Select TableName from Workflow_App where AppID=@AppID and ContengID=@ContentID'"; AllSql="Select WhoDo.CB,App.AppID,App.AppName,Content.RecordID,Content.CurStepID,Content.Subject,Content.ContentID,Content.AppID,WhoDo.LastDoneTime,WhoDo.AppID from Workflow_App App,"+XTableName+" Content,Workflow_Whodo WhoDo where App.AppID=WhoDo.AppID and WhoDo.ContentID=Content.ContentID and UserID="+Session["ID"]+" order by WhoDo.LastDoneTime DESC";我怎么得到@AppID 和@ContentID.....????
[交流]动态SQL语句
set @tablename = '...'
exec('select * from '+@tablename +' where ... ')
楼上的,你这个是放在存储过程里面吗???
我没用过这东西呀。。
declare @tablename
set @tablename = '...'
exec('select * from '+@tablename +' where ... ')
string AllSql=AllSql+"set @tablename = 'Select TableName from Workflow_App where AppID=@AppID and ContengID=@ContentID'";
AllSql="Select WhoDo.CB,App.AppID,App.AppName,Content.RecordID,Content.CurStepID,Content.Subject,Content.ContentID,Content.AppID,WhoDo.LastDoneTime,WhoDo.AppID from Workflow_App App,"+XTableName+" Content,Workflow_Whodo WhoDo where App.AppID=WhoDo.AppID and WhoDo.ContentID=Content.ContentID and UserID="+Session["ID"]+" order by WhoDo.LastDoneTime DESC";我怎么得到@AppID 和@ContentID.....????