exec('declare curFetchRecordField cursor for select name,xtype,length from syscolumns where '+@tableID) open curFetchRecordField 我觉得游标这样动态声明是没有用的
TO:aierong(皑婀瑢-数据库XML.NET联盟会局长) 謝謝提醒,我試試.
TO:aierong(皑婀瑢-数据库XML.NET联盟会局长) 游标这样动态声明是用的.
復制表結構至臨時表中,select top 0 * into 就行了。 if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[tmpRecord]') and OBJECTPROPERTY(id, N'IsUserTable') = 1) drop table [dbo].[tmpRecord] exec('select top 0 * into tmpRecord from '+@strTableName+' where '+@strWhere)
其它的还没看明白。
查询分页,这么累不行。用游标,更不行 每个要查询的表加上主键或,INDETIYI列 比如ID为IDENTITY列 取第201到300的记录:select top 100 * from table where id not in (select top 200 id from table)
我觉得游标这样动态声明是没有用的
謝謝提醒,我試試.
drop table [dbo].[tmpRecord] exec('select top 0 * into tmpRecord from '+@strTableName+' where '+@strWhere)
其它的还没看明白。
每个要查询的表加上主键或,INDETIYI列
比如ID为IDENTITY列
取第201到300的记录:select top 100 * from table where id not in (select top 200 id from table)