IF EXISTS 
(
  SELECT * 
  FROM sys.foreign_key_columns fkc
  INNER JOIN sys.objects obj ON obj.object_id = fkc.constraint_object_id
  INNER JOIN sys.tables tab1 ON tab1.object_id = fkc.parent_object_id
  INNER JOIN sys.columns col1 ON col1.column_id = parent_column_id AND col1.object_id = tab1.object_id
  WHERE obj.name = 'FK_ReportAutomationLogLogPicasso' 
  AND col1.name = 'FK_ReportAutomationId'
)
BEGIN
  ALTER TABLE ReportAutomationLog DROP CONSTRAINT FK_ReportAutomationLogLogPicasso

  ALTER TABLE [dbo].[ReportAutomationLog]  WITH NOCHECK ADD  CONSTRAINT [FK_ReportAutomationLogLogPicasso] FOREIGN KEY([FK_LogPicassoId])
  REFERENCES [dbo].[LogPicasso] ([LogNumber])
END