select DownloadTypeName,DownloadTypeDesc,SelectWord,ParentID,DownloadTypeLevel,IsLeaf,IDTree,MasterID,AddDate,ReleaseDate,iLanguage into Test from DS_DownloadType where SelectWord like '%测试%' and Isleaf=1
insert into Test select DownloadTypeName,DownloadTypeDesc,SelectWord,ParentID,DownloadTypeLevel,IsLeaf,IDTree,MasterID,AddDate,ReleaseDate,iLanguage from DS_DownloadType where (DownloadTypeID not in (select DownloadTypeID from DS_DownloadType where SelectWord like '%测试%' and Isleaf=1) and isleaf=1)
ALTER TABLE Test ADD TempID INT IDENTITY(1,1)
select * from Test order by TempID
drop table Test
ALTER PROCEDURE DS_GetDataList_SelectKeyWord
(
@strWhere1 varchar(1500) = '', -- 或查询条件 (注意: 不要加 where)SelectWord like '%测试%' or SelectWord like '%手机%'
@strWhere2 varchar(1500) = '' -- 与查询条件 (注意: 不要加 where)SelectWord like '%测试%' and SelectWord like '%手机%'
)
AS
declare @strSQL varchar(5000) -- 主语句
declare @strTmp varchar(1000) -- 临时变量
set @strSQL = 'select DownloadTypeName,DownloadTypeDesc,SelectWord,ParentID,DownloadTypeLevel,IsLeaf,IDTree,MasterID,AddDate,ReleaseDate,iLanguage into DS_Test from DS_DownloadType where DownloadTypeID not in (select DownloadTypeID from DS_DownloadType where ('+ @strWhere1 +') and Isleaf=1) and isleaf=1'
exec (@strSQL)
set @strSQL = 'insert into DS_Test select DownloadTypeName,DownloadTypeDesc,SelectWord,ParentID,DownloadTypeLevel,IsLeaf,IDTree,MasterID,AddDate,ReleaseDate,iLanguage from DS_DownloadType where ('+ @strWhere2 +') and Isleaf=1'
exec (@strSQL)
set @strSQL = 'insert into DS_Test select DownloadTypeName,DownloadTypeDesc,SelectWord,ParentID,DownloadTypeLevel,IsLeaf,IDTree,MasterID,AddDate,ReleaseDate,iLanguage from DS_DownloadType where ('+ @strWhere1 +') and not ('+ @strWhere2 +') and Isleaf=1'
exec (@strSQL)
exec ('ALTER TABLE DS_Test ADD TempID INT IDENTITY(1,1)')
exec ('select * from DS_Test order by TempID')
exec ('drop table DS_Test')