Blog Pages

SAP ASE (Sybase) - Create FOREIGN KEY on exists table

IF NOT EXISTS (select * from sysobjects where name = 'FK_NAME' and type = 'RI')
  ALTER TABLE [dbo].[TABLENAME] ADD CONSTRAINT FK_NAME FOREIGN KEY ([COLUMNNAME])
  REFERENCES [dbo].[REF_TABLENAME] ([REF_COLUMNNAME])
GO

No comments:

Post a Comment