sybase 用identity做分页时 遇到identity字段 怎么处理?很急!!!!!

baggiogamp 2008-05-07
问题如下
我用identity 在sybase中作了分页

但如果表中有 identity 字段这个分页就会报错.

set rowcount 2
SELECT LOGSID,FILENAME,CREATEDATE,USERID,LINAGE,DESCRIPTION,sybid=identity(12) into #temptable1 FROM 
STALOG WHERE  tablename='QUESTIONS' or tablename='QUESTION_CHOICE' or tablename='QUESTION_FILL'
or tablename='QUESTION_MATCH' or tablename='Q_SUBJECTIFY' or tablename='MA_QUPOOL'  ORDER BY LOGSID

select * from #temptable1 where sybid>0 and sybid <=2 
set rowcount 0
drop table #temptable1 commit transaction

例子如上, 其中 STALOG表的 LOGSID字段是 identity的
报的错误是
Attempting to add a new identity field to a table '#temptable1', via select into, which would have a field 'LOGSID' that inherits the identity property.

请问怎么解决呢 ?
baggiogamp 2008-05-08
解决办法如下
set rowcount 2
SELECT convert(vchar,logsid) logsid ,FILENAME,CREATEDATE,USERID,LINAGE,DESCRIPTION,sybid=identity(12) into #temptable1 FROM 
STALOG WHERE  tablename='QUESTIONS' or tablename='QUESTION_CHOICE' or tablename='QUESTION_FILL'
or tablename='QUESTION_MATCH' or tablename='Q_SUBJECTIFY' or tablename='MA_QUPOOL'  ORDER BY LOGSID

select * from #temptable1 where sybid>0 and sybid <=2 
set rowcount 0
drop table #temptable1 commit transaction

这样就行了,把identity类型的转换下,在放到临时表里.
Global site tag (gtag.js) - Google Analytics