Script generating with table rename and reinsert data
Here is some table need to recreate and refill data after if. Recreation reason- identity increment has been changed.
This script was generated:
IF OBJECTID(N'dbo.EDDevicesSHADOW', 'U') IS NOT NULL
AND OBJECTID(N'dbo.tmpdevartEDDevicesSHADOW', 'U') IS NULL
EXEC sprename N'dbo.EDDevicesSHADOW', N'tmpdevartEDDevices_SHADOW', 'OBJECT'
GO
IF NOT EXISTS (
SELECT 1 FROM sys.indexes
WHERE name = N'PKEDDevicesSHADOW' AND objectid = OBJECTID(N'dbo.EDDevicesSHADOW'))
AND EXISTS (
SELECT 1 FROM sys.indexes
WHERE name = N'PKEDDevicesSHADOW' AND objectid = OBJECTID(N'dbo.EDDevicesSHADOW'))
EXEC sprename N'dbo.PKEDDevicesSHADOW', N'tmpdevartPKEDDevices_SHADOW', 'OBJECT'
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'SRowGUID' AND objectid = OBJECTID(N'dbo.EDDevicesSHADOW', 'U') AND defaultobjectid <> 0)
AND EXISTS (SELECT 1 FROM sys.columns WHERE name = N'SRowGUID' AND objectid = OBJECTID(N'dbo.EDDevicesSHADOW', 'U') AND defaultobjectid <> 0)
EXEC sprename N'dbo.DFEDDevicesSHADOWSRowGUID', N'tmpdevartDFEDDevicesSHADOWS_RowGUID', 'OBJECT'
GO
IF OBJECTID(N'dbo.EDDevicesSHADOW', 'U') IS NULL
CREATE TABLE dbo.EDDevices_SHADOW (....
...
As we can see some statements logic never fire. And we have incorrect database updating script.
-
Anonymous commented
+1