回答

收藏

列与取消透视表中其他列的类型冲突

技术问答 技术问答 115 人阅读 | 0 人回复 | 2023-09-13

我sys.[views]将重点放在关键值上,以便与另一台服务器上的值进行比较,以进行一致性测试。我遇到了一个返回错误的问题。
1 b5 e* T. Q! q. K# W! }& k  nMsg 8167,16级,状态1,51行: y3 K) c3 K2 Z
列出类型的类型和UNPIVOT列表中指定的其他列类型的冲突。
. }6 b3 I& L3 I$ t
询问:
6 w$ F) u$ i! t+ X5 V3 ~; I1 t( JSELECTsourceUnpivoted.idServer,sourceUnpivoted.sourceServerName,sourceUnpivoted.name,sourceUnpivoted.columnName,sourceUnpivoted.columnValueFROM (SELECT CAST('1' AS VARCHAR(255)) AS idServer,CAST('thisOne' AS VARCHAR(255)) AS sourceServerName,CAST('theDatabase' AS VARCHAR(255)) AS sourceDatabaseName,CAST(name AS VARCHAR(255)) AS name,CAST(object_id AS VARCHAR(255)) AS object_id,CAST(principal_id AS VARCHAR(255)) AS principal_id,CAST(schema_id AS VARCHAR(255)) AS schema_id,CAST(parent_object_id AS VARCHAR(255)) AS parent_object_id,CAST(type AS VARCHAR(255)) AS type,CAST(type_desc AS VARCHAR(255)) AS type_desc,CAST(create_date AS VARCHAR(255)) AS create_date,CAST(lock_escalation_desc AS VARCHAR(255)) AS lock_escalation_desc...FROM noc_test.dbo.stage_sysTables) AS databaseTablesUNPIVOT (columnValue FOR columnName IN (object_id,principal_id,schema_id,parent_object_id,type,type_desc,create_date,lock_escalation_desc) ) AS sourceUnpivoted为什么不喜欢呢?[type],[type_desc],[lock_escalation_desc]???1 [( M  C+ o* z/ h  t( E
我也尝试过CONVERT(VARCHAR(255),type) AS type) y1 S6 f1 z( P# \0 v$ \
                                                               
0 Q/ [, o- N0 j0 s8 c  c    解决方案:
分享到:
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则