Hi,
In the 1st "if exists" condition above what is the actual flow?
To me, I read it as if the condition is true then both the drop and "create index" commands will run. And if it is false, then neither drop or create commands runs. I copied this from ssms and had to take all the go commands out for it to work in vfp.
I don't remember exactly, but I believe it had a go after the drop command and then one after the "create index" command. If this is correct, is it ok to assume that the sql go command stops or implicitly ends the "if exists" statement?
So, to get the intended functionality that Sql's "create index script generator" creates for Sql Server, I would need to change it to this to use in Vfp?:
Code:
TEXT to m.lcSqlStr textmerge NOSHOW PRETEXT 15
Use [<<gcSqlDbName>>]
IF EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[BookID]') AND name = N'IsDeleted')
DROP INDEX [IsDeleted] ON [dbo].[BookID] WITH ( ONLINE = OFF )
CREATE INDEX IsDeleted ON bookid (is_deleted)
IF EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[BookID]') AND name = N'SystemId')
DROP INDEX [SystemId] ON [dbo].[BookID] WITH ( ONLINE = OFF )
CREATE INDEX SystemId ON BookID (system_id)
ENDTEXT
In the 1st "if exists" condition above what is the actual flow?
To me, I read it as if the condition is true then both the drop and "create index" commands will run. And if it is false, then neither drop or create commands runs. I copied this from ssms and had to take all the go commands out for it to work in vfp.
I don't remember exactly, but I believe it had a go after the drop command and then one after the "create index" command. If this is correct, is it ok to assume that the sql go command stops or implicitly ends the "if exists" statement?
So, to get the intended functionality that Sql's "create index script generator" creates for Sql Server, I would need to change it to this to use in Vfp?:
Code:
IF EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[BookID]') AND name = N'IsDeleted')
DROP INDEX [IsDeleted] ON [dbo].[BookID] WITH ( ONLINE = OFF )
end if
CREATE INDEX IsDeleted ON bookid (is_deleted)