SQL Finding the size of query result

2020-05-23 03:29发布

So basically I'm doing a SQL select query, but I want to know how much data I am pulling back (how many kilobytes), any way?

4条回答
欢心
2楼-- · 2020-05-23 03:42

You can include the actual execution plan of the query in the Results window of SSMS, which will display an estimated row size for the results. Multiply that by the number of rows to get your result. Not sure how accurate the estimated row size is, though.

查看更多
狗以群分
3楼-- · 2020-05-23 03:47

Actually, "Show Client Statistics" within SSMS query Editor Window will return the resultset size, Bytes Received from Server, etc

查看更多
虎瘦雄心在
4楼-- · 2020-05-23 03:55
SELECT <your query here>
INTO dbo.MyTempTable
FROM <query source>

exec sp_spaceused 'MyTempTable'

DROP TABLE MyTempTable

This wlil Return Rows, Reserved Space, Data space (in KB), Index space, and unused space for that table.

查看更多
Luminary・发光体
5楼-- · 2020-05-23 04:00

You can use sp_spaceused to get the size of a table. But I am unaware of any way to get the size of a query (of course that means little).

One way to get a quick estimate of the size would be to save the data as a text file. Obviously, there will be extra whitespace. But it would give you a general idea on how large the query is.

查看更多
登录 后发表回答