Below script finds dependant objects for a given object.
declare @server varchar(50) = 'sql server name'
declare @db varchar(50) = 'database name'
declare @schema varchar(50) = 'schema name'
declare @object varchar(50) = 'object name'
create table #t
(
[ReferencingDatabase] varchar(100),
[ReferencingSchema] varchar(100),
[ReferencingObject] varchar(100),
[ReferencingObjectType] varchar(100)
)
declare @cmd1 varchar(8000)
set @cmd1 = '
if ''?'' not in (''distribution'', ''master'', ''model'', ''msdb'', ''tempdb'', ''mssqlsystemresource'')
begin
insert into #t
select
''?'' as [ReferencingObjectDatabase],
s.name as [ReferencingObjectSchema],
o.name as [ReferencingObjectName],
o.type_desc as [ReferencingObjectType]
from ?.sys.sql_expression_dependencies d
inner join ?.sys.objects o on o.object_id = d.referencing_id
inner join ?.sys.schemas s on s.schema_id = o.schema_id
where d.referenced_entity_name = ''' + @object + '''
and (d.referenced_server_name = ''' + @server + ''' or d.referenced_server_name is null)
and (d.referenced_database_name = ''' + @db + ''' or d.referenced_database_name is null)
and (d.referenced_schema_name = ''' + @schema + ''' or d.referenced_schema_name = '''' or d.referenced_schema_name is null)
end
'
exec sp_msforeachdb @cmd1
select * from #t
drop table #t
Monday, November 5, 2012
Tuesday, March 13, 2012
SOA Tips
I learned some tips about implementing service oriented architecture by experiencing the difficulties that emerged because we didn't care about them.
A. SOA does not mean that you're not going to do object oriented design.
B. Each client should call only one service method to do one job. Otherwise:
Friday, December 23, 2011
TFS vNext needs audit log reports
Because of some governmental regulations, we need to report the administrative actions over permissions on TFS. Auditors frequently request such reports from us.
I requested the audit logs of administrative actions over permissions on TFS from Microsoft in the VS vNext Wish List.
We'll see what Microsoft thinks about adding audit reports to TFS in the next version. What do you think, is it worth?
I requested the audit logs of administrative actions over permissions on TFS from Microsoft in the VS vNext Wish List.
We'll see what Microsoft thinks about adding audit reports to TFS in the next version. What do you think, is it worth?
Thursday, December 22, 2011
TFS Case Study of Microsoft Turkiye
Microsoft Turkiye examined our TFS implementation and published a case study document:
https://blog.microsoft.com.tr/turkiye-finans-katilim-bankasi.html
Unfortunately the document is prepared only for Turkish audience, it has no English translation.
https://blog.microsoft.com.tr/turkiye-finans-katilim-bankasi.html
Unfortunately the document is prepared only for Turkish audience, it has no English translation.
Sunday, June 19, 2011
Count lines of code in a database
Here is a small script to count lines of code in a database:
select
o.type_desc as ObjectType
,count(*) as [ObjectCount]
,sum(len(m.definition) - len(replace(m.definition, char(13), ''))) as [TotalLineCount]
from sys.objects o
inner join sys.sql_modules m on o.object_id = m.object_id
where o.[type] in ('P', 'TR', 'FN', 'IF', 'V', 'TF')
and o.name not like 'aspnet[_]%'
and o.name not like 'vw[_]aspnet[_]%'
group by o.type_desc
order by o.type_desc
Monday, May 30, 2011
Sign a .Net assembly without the source code
Two different versions of an old .Net assembly caused some deployment problems. We wanted to deploy the assembly to the GAC but neither of the two versions were signed. We needed to sign the assemblies but we did not have the source code.
After a small search I found a great tool named ILMerge.
Main purpose of ILMerge is to combine more than one .Net assemblies into one assembly. The side benefit is that you can also sign the resulting assembly. It works while working with only one assembly too. This way you can sign an assembly without having the source code.
Sample command line:
ilmerge /t:library /keyfile:"c:\SomeKeyFile.snk" /out:"c:\signed\assembly.dll" "c:\unsigned\assembly.dll"
Wednesday, May 4, 2011
Entity framework class generator
I wrote a sql script to generate entity framework POCO classes: https://gist.github.com/954916
Script considers primary and foreign keys including both "one to one" and "one to many" relations.
It also writes sql object descriptions saved as extended properties to the class and property comments of POCO classes.
It is working for MS SQL 2008 and 2008 R2. I did not try to run the script on other versions.
Script considers primary and foreign keys including both "one to one" and "one to many" relations.
It also writes sql object descriptions saved as extended properties to the class and property comments of POCO classes.
It is working for MS SQL 2008 and 2008 R2. I did not try to run the script on other versions.
Subscribe to:
Posts (Atom)
