TSQL - 为什么在创建 nVarChar 列时创建 sysname?
TSQL - Why sysname is created when I create nVarChar column?
我的 tsql 数据中有一个 tabletable:
CREATE TABLE dbo.Test
(
Col nVarChar (50) null
)
GO
然后我执行查询:
Select
c.name As Name, ty.name as Type, c.max_length As MaxLenght, c.precision As Precision, c.scale As Scale, c.is_nullable As IsNullable, *
From
sys.schemas s
inner join sys.tables t on s.schema_id = t.schema_id
inner join sys.columns c on t.object_id = c.object_id
inner join sys.types ty on ty.system_type_id = c.system_type_id
Where
s.name LIKE 'dbo' AND t.name LIKE 'Test'
问题是……为什么会有Two Rows?!
检查这个:
SELECT ROW_NUMBER() OVER(PARTITION BY system_type_id ORDER BY system_type_id)
, *
FROM sys.types;
检查第一列的值 >1...
映射到相同 system_type_id
的类型很少。有些名字只是其他东西的别名...
更新
This question 解决了同样的问题...
我的 tsql 数据中有一个 tabletable:
CREATE TABLE dbo.Test
(
Col nVarChar (50) null
)
GO
然后我执行查询:
Select
c.name As Name, ty.name as Type, c.max_length As MaxLenght, c.precision As Precision, c.scale As Scale, c.is_nullable As IsNullable, *
From
sys.schemas s
inner join sys.tables t on s.schema_id = t.schema_id
inner join sys.columns c on t.object_id = c.object_id
inner join sys.types ty on ty.system_type_id = c.system_type_id
Where
s.name LIKE 'dbo' AND t.name LIKE 'Test'
问题是……为什么会有Two Rows?!
检查这个:
SELECT ROW_NUMBER() OVER(PARTITION BY system_type_id ORDER BY system_type_id)
, *
FROM sys.types;
检查第一列的值 >1...
映射到相同 system_type_id
的类型很少。有些名字只是其他东西的别名...
更新
This question 解决了同样的问题...