Skip to content

Instantly share code, notes, and snippets.

@kadru
Last active January 28, 2019 15:56
Show Gist options
  • Save kadru/9d29852c96f2442e51545f9d5348de4a to your computer and use it in GitHub Desktop.
Save kadru/9d29852c96f2442e51545f9d5348de4a to your computer and use it in GitHub Desktop.
autofix and other utilities sql server.sql
EXEC sp_change_users_login 'Auto_Fix', 'user', NULL, 'pass'
-- constraints information
SELECT * FROM sys.objects
WHERE type_desc LIKE '%CONSTRAINT'
SELECT *
FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS
where CONSTRAINT_NAME = 'constraint_name'
SELECT OBJECT_NAME(object_id) AS ConstraintName,
SCHEMA_NAME(schema_id) AS SchemaName,
type_desc AS ConstraintType
FROM sys.objects
WHERE type_desc LIKE '%CONSTRAINT' AND OBJECT_NAME(parent_object_id)='constraint_nem'
--constraints from a table
exec sp_helpconstraint 'table_name'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment