Tag Info

New answers tagged


The problem is with the erp.table, you are defining primary keys multiple times. Try the following code: CREATE TABLE [erp].[table]( [SysRevID] [timestamp] NOT NULL, [SysRowID] [uniqueidentifier] ROWGUIDCOL NOT NULL DEFAULT (CONVERT([uniqueidentifier],CONVERT([binary](10),newid(),(0))+CONVERT([binary](6),getutcdate(),(0)),(0))), [Company] ...


You can use INFORMATION_SCHEMA KEY_COLUMN_USAGE table. SELECT table_name AS TableName, column_name AS ColumnName, Constraint_name as ConstraintName FROM information_schema.key_column_usage WHERE table_schema = 'database_name' Updated code based on OP's requirement: SELECT DISTINCT(TC.table_name) AS TableName, KC.column_name as ColumnName, TC. ...

Top 50 recent answers are included