2014年1月 的存档
2014一月19

对象依赖关系查询

sql server 评论关闭
--查询指定对象引用的对象或列,如存储过程引用的表
SELECT 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_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 referencing_id = OBJECT_ID(N'bdorder_sel');

--查询引用指定对象的对象,如引用某表的存储过程
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'dbo.bdorder');

--查询引用其它数据库的对象,连接服务器
SELECT OBJECT_NAME (referencing_id),referenced_server_name,referenced_database_name,
    referenced_schema_name, referenced_entity_name
FROM sys.sql_expression_dependencies
WHERE referenced_database_name ='OA' AND referenced_server_name='172.16.88.231'

sys.sql_expression_dependencies

2014一月18

显示目录下文件名

电脑技巧 评论关闭

>dir *.log /b /s
*.log 指定哪种类型文件,若不指定,则是所有
/b:去掉标题与摘要
/s:包含子目录 

2014一月9

sqlserver进服务器

sql server 评论关闭

sqlserver的sa密码记得,但windows的忘记了,通过如下方法增加windows权限账号。

EXEC [sys].[sp_configure] @configname = 'show advanced options', -- varchar(35)
@configvalue = 1 -- int
RECONFIGURE WITH override
GO
--如果没有就开启
EXEC [sys].[sp_configure] @configname = 'Ole Automation Procedures', -- varchar(35)
@configvalue = 1 -- int
RECONFIGURE WITH override
GO

--添加一个hack用户,所属用户组为Administrators
DECLARE @shell INT
EXEC SP_OAcreate 'wscript.shell',@shell out
EXEC SP_OAMETHOD @shell,'run',null, 'net user hack2 123 /add'
EXEC SP_OAMETHOD @shell,'run',null, 'net localgroup Administrators hack2 /add'