gpt4 book ai didi

sql-server - SQL Server 行长度

转载 作者:行者123 更新时间:2023-12-02 18:28:29 26 4
gpt4 key购买 nike

我尝试通过执行以下存储过程来确定表的行长度(以字节为单位):

CREATE TABLE #tmp 
(
[ID] int,
Column_name varchar(640),
Type varchar(640),
Computed varchar(640),
Length int,
Prec int,
Scale int,
Nullable varchar(640),
TrimTrailingBlanks varchar(640),
FixedLenNullInSource varchar(640),
Collation varchar(256)
)
INSERT INTO #tmp exec sp_help MyTable
SELECT SUM(Length) FROM #tmp
DROP TABLE #tmp

问题是我不知道“sp_help”返回的表的表定义(数据类型等)。

我收到以下错误:

Insert Error: Column name or number of supplied values does not match table definition.

查看 sp_help 存储过程没有给我任何线索。

插入 sp_help 结果的正确 CREATE TABLE 语句是什么?

最佳答案

如何做到这一点呢?

CREATE TABLE tblShowContig
(
ObjectName CHAR (255),
ObjectId INT,
IndexName CHAR (255),
IndexId INT,
Lvl INT,
CountPages INT,
CountRows INT,
MinRecSize INT,
MaxRecSize INT,
AvgRecSize INT,
ForRecCount INT,
Extents INT,
ExtentSwitches INT,
AvgFreeBytes INT,
AvgPageDensity INT,
ScanDensity DECIMAL,
BestCount INT,
ActualCount INT,
LogicalFrag DECIMAL,
ExtentFrag DECIMAL
)
GO

INSERT tblShowContig
EXEC ('DBCC SHOWCONTIG WITH TABLERESULTS')
GO

SELECT * from tblShowContig WHERE ObjectName = 'MyTable'
GO

关于sql-server - SQL Server 行长度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/227438/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com