我有一个带有繁重逻辑/数据处理组件的SQL Server数据库。 大量原始表,“工作表”,sprocs,函数,视图。作品。
我的任务是将一个特定的概念值转换为处理到3 d.p. Yeuch!
命名也不错,所以你通常可以判断一个列/变量/参数是否只是从它的名字中保存这种类型的数据。
到目前为止,我已经检查过了:
INFORMATION_SCHEMA.COLUMNS
)INFORMATION_SCHEMA.PARAMETERS
)DECLARE
,CAST
和CONVERT
有没有人对我可能错过的地方有任何建议,可能会默默地将这些值中的一个存储为int(或错误的精度)?
答案 0 :(得分:0)
如果你想在SP / view / ufn定义中找到它,这可能会有所帮助(从字面上搜索定义,因此可以用来查找任何类型的字符串):
SELECT DISTINCT
o.name AS Object_Name
, o.type_desc
FROM
sys.sql_modules m
INNER JOIN sys.objects o
ON m.object_id = o.object_id
WHERE
m.definition Like '%$ObjectName$%'
否则你可以找到引用,依赖对象使用这些(仅适用于对象,因此没有列名,但你也可以一直加入sys.columns)
SELECT
referencing_schema_name
, referencing_entity_name
, referencing_id
, referencing_class_desc
, is_caller_dependent
FROM
sys.dm_sql_referencing_entities ('$ObjectName$', 'OBJECT')
;
SELECT
referenced_id
, referenced_entity_name AS table_name
, referenced_minor_name as column_name
, is_all_columns_found
FROM
sys.dm_sql_referenced_entities ('$ObjectName$', 'OBJECT')
;
SELECT
OBJECT_SCHEMA_NAME ( referencing_id ) AS referencing_schema_name,
OBJECT_NAME(referencing_id) AS referencing_entity_name,
o.type_desc AS referencing_desciption,
COALESCE(COL_NAME(referencing_id, referencing_minor_id), '(n/a)') AS referencing_minor_id,
referencing_class_desc, referenced_class_desc,
referenced_server_name, referenced_database_name, referenced_schema_name,
referenced_entity_name,
COALESCE(COL_NAME(referenced_id, referenced_minor_id), '(n/a)') AS referenced_column_name,
is_caller_dependent, is_ambiguous
FROM
sys.sql_expression_dependencies AS sed
INNER JOIN sys.objects AS o
ON sed.referencing_id = o.object_id
WHERE
referenced_id = OBJECT_ID(N'$ObjectName$')
;