如果表有超过10000条记录,如何使用where条件从sql server中选择数据? [英] How to select data form sql server using where condition if table have more than 10000 records ?

查看:522
本文介绍了如果表有超过10000条记录,如何使用where条件从sql server中选择数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我有一个表,因为更多的10000条记录,在一个字段中可能是也可能不是NULL,我需要获取记录,这些字段是10000条记录中的NULL .Below是我的表字段。< br $>


Hi I have one table,in that more 10000 records,in one fields is may or may not NULL,i need to get records ,those fields are NULL from 10000 records.Below is my table fields.

DocumentName, [Document], Path, Version,SWF





在本文档和SWF字段是文件流中,我的意思是我在该字段中存储文件的二进制数据。所有文档字段行都获得二进制数据,但SWF字段某些行为NULL。

所以这里我需要从超过10000条记录中获取哪些SWF字段为NULL。

如果我使用以下查询



In this Document and SWF fields are file stream,i mean i store binary data of files in that fields.All row of Document fields got binary data,but SWF fields some row is NULL.
So here i need to get which SWF fields is NULL from more than 10000 records.
If i use following query

select DocumentName, [Document], Path, Version,SWF from FTRepository where ([SWF] IS NULL)





显示Timeout expired错误,这里我附上截图链接

http://prntscr.com/6rfidq [ ^ ]





如果我使用以下查询仍然显示相同的错误,这里我使用顶部200与where条件,如果没有where条件得到结果,但我需要条件,但这不是一个好主意,bcz总是检索最多200条记录,我的意思是它所有时间检索相同的200条记录,它不会移动下200条记录表格10000条记录



It show "Timeout expired" error,here i attach screenshot link
http://prntscr.com/6rfidq[^]


IF i use following query still show same error,here i use top of 200 with where condition,if without where condition get result,but i need where condition,But this is not good idea,bcz always it retrieve top most 200 records,i mean all time it retrieve same 200 records,it not move next 200 records form 10000 records

select Top (200) DocumentName, [Document], Path, Version,SWF from FTRepository where ([SWF] IS NULL)





所以如何解决这个问题。



第二个问题



我有超过10000 rec在FTRepository表中的ords,在我需要检索前200条记录,在前200条记录的过程之后,然后需要移动下200条记录,然后接下来的200条记录等等,我的意思是在超过10000条记录中我将溢出200,200 ...记录和处理200条记录等...

这里不需要条件(SWF为空),只需要200,200 .....记录形式超过10000记录。







记录

Araind



So how to solve this.

And second question

I have more that 10000 records in FTRepository table,in that i need to retrieve first 200 records,after process with first 200 records,then need to move next 200 records,and then next 200 records and so on,i mean in more than 10000 records i will spilt 200,200 ... records and process with 200 records and so on...
Here no need where condition (SWF is null),just i need to take 200,200..... records form more than 10000 records.



Records
Araind

推荐答案

SWF列上的索引可能会有所帮助 - 约10k行不是很多......



SQLServer2012有 OFFSET / FETCH [ ^ ]这样的分页关键字,失败谷歌的 SQL分页方法 [ ^ ]
an index on the SWF column would probably help - ~10k rows is not a lot ...

SQLServer2012 has the OFFSET/FETCH[^] keywords for pagination like that, failing that google for SQL Pagination methods[^]


这篇关于如果表有超过10000条记录,如何使用where条件从sql server中选择数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆