Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/sql-server/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sql server sp_spaceused和DataLength SQL Server之间的差异_Sql Server_Sql Server 2005_Datalength - Fatal编程技术网

Sql server sp_spaceused和DataLength SQL Server之间的差异

Sql server sp_spaceused和DataLength SQL Server之间的差异,sql-server,sql-server-2005,datalength,Sql Server,Sql Server 2005,Datalength,当我使用SP_SpaceUsed N“”时,我有一个单行表,它提供的数据为16 KB 当我使用dataLength时,比如:- select ClientID , (0 + isnull(datalength(ClientID), 1) + isnull(datalength(LeadID), 1) + isnull(datalength(Company_Name), 1) + isnull(datalength(Website), 1) + isnull(datalength(Emp

当我使用SP_SpaceUsed N“”时,我有一个单行表,它提供的数据为16 KB

当我使用dataLength时,比如:-

select ClientID , (0 + isnull(datalength(ClientID), 1) + isnull(datalength(LeadID), 1) + isnull(datalength(Company_Name), 1) + isnull(datalength(Website), 1) + isnull(datalength(EmployeeCount), 1) + isnull(datalength(Revenue), 1) + isnull(datalength(Address), 1) + isnull(datalength(City), 1) + isnull(datalength(State), 1) + isnull(datalength(ZipCode), 1) + isnull(datalength(CountryID), 1) + isnull(datalength(Phone), 1) + isnull(datalength(Fax), 1) + isnull(datalength(TimeZone), 1) + isnull(datalength(SicNo), 1) + isnull(datalength(SicDesc), 1) + isnull(datalength(ResearchAnalysis), 1) + isnull(datalength(SourceID), 1) + isnull(datalength(BasketID), 1) + isnull(datalength(PipelineStatusID), 1) + isnull(datalength(SurveryID), 1) + isnull(datalength(NextCallDt), 1) + isnull(datalength(CurrentRecStatus), 1) + isnull(datalength(AssignedUserID), 1) + isnull(datalength(AssignedDate), 1) + isnull(datalength(TotValueAmt), 1) + isnull(datalength(Remove), 1) + isnull(datalength(Release), 1) + isnull(datalength(LegendID), 1) + isnull(datalength(Inserted_Date), 1) + isnull(datalength(Inserted_By), 1) + isnull(datalength(Updated_Date), 1) + isnull(datalength(Updated_By), 1)) as rowsize from TempLeadHeader order by rowsize desc 选择ClientID, (0+isnull(数据长度(ClientID),1)+ isnull(数据长度(引线ID),1+ isnull(数据长度(公司名称),1+ isnull(数据长度(网站),1+ isnull(数据长度(EmployeeCount),1+ isnull(数据长度(收入),1)+ isnull(数据长度(地址),1+ isnull(数据长度(城市),1+ isnull(数据长度(状态),1+ isnull(数据长度(ZipCode),1+ isnull(数据长度(CountryID),1+ isnull(数据长度(电话),1+ isnull(数据长度(传真),1+ isnull(数据长度(时区),1+ isnull(数据长度(SicNo),1+ isnull(数据长度(SicDesc),1)+ isnull(数据长度(研究分析),1+ isnull(数据长度(源ID),1+ isnull(数据长度(BasketID),1+ isnull(数据长度(PipelineStatusID),1+ isnull(数据长度(SurveryID),1+ isnull(数据长度(NextCallDt),1+ isnull(数据长度(CurrentRecStatus),1)+ isnull(数据长度(赋值序列号),1+ isnull(数据长度(赋值日期),1+ isnull(数据长度(TotValueAmt),1+ isnull(数据长度(删除),1+ isnull(数据长度(发布版),1+ isnull(数据长度(LegendID),1+ isnull(数据长度(插入日期),1)+ isnull(数据长度(插入者),1+ isnull(数据长度(更新日期),1+ isnull(数据长度(更新者),1)) 按rowsize desc从TempLeadHeader排序作为rowsize 它给出了行大小167,我想这是以字节为单位的

我想知道为什么结果会出现这种差异


提前感谢

sp_spaceused统计页面使用的空间,即8k块。 请记住,表还包括占用空间的索引之类的内容。更不用说页面上的数据永远不会满,除非填充系数为100%


datalength将告诉您列的字节数

如果将一行与一个表进行比较,则必须对每一行进行求和,即使如此,也不会相同,因为您没有显示标题信息和索引数据

你也可以这样做

dbcc showcontig ('TempLeadHeader') with tableresults
然后查看最小、最大和平均记录大小列