Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
140 lines (90 sloc) 2.59 KB
set noexec off
go
/*
exec sp_helpuser
*/
if (
( SUSER_ID('rdsa') is not null )
and ( db_name() = 'master')
)
begin
print 'We are on Amazon AWS/RDS and cannot create objects in the master database'
print 'Please stop processing!'
set noexec on
end
go
if SUSER_ID('rdsa') is null
begin
use [master]
end
go
if object_id('[dbo].[sp_helpConstraintDefault]') is null
begin
exec('create procedure [dbo].[sp_helpConstraintDefault] as ')
end
go
alter procedure [dbo].[sp_helpConstraintDefault]
as
begin
select
[schema]
= tblSS.[name]
, [object]
= tblSO.[name]
, [column]
= tblSC.[name]
, [columnType]
= tblST.[name]
, [is_identity]
= tblSC.is_identity
, [is_rowguidcol]
= tblSC.is_rowguidcol
, [columnDefault]
= tblSDC.[name]
, [definition]
= tblSDC.[definition]
, [referencedObject]
= quotename
(
tblSORefS.[name]
)
+ '.'
+ quoteName
(
tblSORef.[name]
)
, [referencedObjectType]
= tblSORef.[type_desc]
from sys.columns tblSC
inner join sys.types tblST
on tblSC.system_type_id = tblST.system_type_id
and tblSC.user_type_id = tblST.user_type_id
inner join sys.objects tblSO
on tblSC.[object_id] = tblSO.[object_id]
inner join sys.schemas tblSS
on tblSO.[schema_id] = tblSS.[schema_id]
inner join sys.default_constraints tblSDC
on tblSC.object_id = tblSDC.parent_object_id
and tblSC.column_id = tblSDC.parent_column_id
left outer join sys.sql_expression_dependencies AS tblSSED
on tblSC.[default_object_id] = tblSSED.referencing_id
left outer join sys.objects tblSORef
on tblSSED.referenced_id = tblSORef.[object_id]
left outer join sys.schemas tblSORefS
on tblSORef.[schema_id] = tblSORefS.[schema_id]
order by
tblSS.[name]
, tblSO.[name]
, tblSC.[name]
end
go
/*
We are on RDS, please skip marking as system object!'
*/
if SUSER_ID('rdsa') is null
begin
exec sp_MS_marksystemobject '[dbo].[sp_helpConstraintDefault]'
end
go
set noexec off
go
You can’t perform that action at this time.