Hi Leuz,
ich solle in Updatescript fürs Gschäft schreiben und da muss ich prüfen ob ein Index auf einer Tabelle schon existiert.
So hat ich es erst:
CREATE INDEX [iX_adisJobExecutionLog_JobHistoryId] ON [dbo].[adisJobExecutionLog]([JobHistoryId], [LogIdentity], [Deleted]) WITH DROP_EXISTING ON [PRIMARY]
Funktioniert aber nicht, wahrscheinlich wegen den SQL-Syntaxänderungen beim SQL Server Management Studio 2005
So wollt ich es jetzt machen(d.h. zumindest irgendwie :mod: ):
IF(EXISTS (INDEX [iX_adisJobExecutionLog_JobHistoryId] ON [dbo].[adisJobExecutionLog] ))
BEGIN
DROP INDEX [iX_adisJobExecutionLog_JobHistoryId] ON [dbo].[adisJobExecutionLog]
CREATE INDEX [iX_adisJobExecutionLog_JobHistoryId] ON [dbo].[adisJobExecutionLog]([JobHistoryId], [LogIdentity], [Deleted])
END
ELSE
CREATE INDEX [iX_adisJobExecutionLog_JobHistoryId] ON [dbo].[adisJobExecutionLog]([JobHistoryId], [LogIdentity], [Deleted])
Allerdings hab ich hier noch bei meiner Bedingung ein Problem und beim Then-Zweig... Das mit dem Then-Zweig bekomm ich hin, nur die Bedingung raff ich nicht so ganz.
Bitte helft mir und thx im Vorraus...
GrEEtInGs bY Grinse-Hinze