Formatting issue with dropping foreign keys in output script
clamk123
Posts: 40
There's a slight bug when generating an output script in the case of foreign keys which affects formatting (and in our case, parsing the script).
When generating a comparison script between tables with foreign keys, you get the below sample results.
GO
PRINT N'Dropping foreign keys from [dbo].[tblTable2]'
GO
ALTER TABLE [dbo].[tblTable2] DROP CONSTRAINT[FK_NamedId]
GO
PRINT N'Dropping constraints from [dbo].[tblTable]'
GO
ALTER TABLE [dbo].[tblTable] DROP CONSTRAINT [df]
GO
PRINT N'Dropping constraints from [dbo].[tblTable3]'
GO
ALTER TABLE [dbo].[tblTable3] DROP CONSTRAINT [df_tblTable2_value]
GO
If you look closely, you can see that DROP CONSTRAINT [...] has a space between CONSTRAINT and the bracketed object name. When it generates the script for foreign keys, it does not have a space, and CONSTRAINT and the '[' are next to each other. This doesn't prevent the script from running, but does interefere with our parsing routines that occur on the generated script which is expecting to find a space between them. If this could be resolved that would be appreciated.
When generating a comparison script between tables with foreign keys, you get the below sample results.
GO
PRINT N'Dropping foreign keys from [dbo].[tblTable2]'
GO
ALTER TABLE [dbo].[tblTable2] DROP CONSTRAINT[FK_NamedId]
GO
PRINT N'Dropping constraints from [dbo].[tblTable]'
GO
ALTER TABLE [dbo].[tblTable] DROP CONSTRAINT [df]
GO
PRINT N'Dropping constraints from [dbo].[tblTable3]'
GO
ALTER TABLE [dbo].[tblTable3] DROP CONSTRAINT [df_tblTable2_value]
GO
If you look closely, you can see that DROP CONSTRAINT [...] has a space between CONSTRAINT and the bracketed object name. When it generates the script for foreign keys, it does not have a space, and CONSTRAINT and the '[' are next to each other. This doesn't prevent the script from running, but does interefere with our parsing routines that occur on the generated script which is expecting to find a space between them. If this could be resolved that would be appreciated.
Comments
I can't make any promise of timescale, however if it's a simple fix it may be possible to get done quite quickly.
Redgate Software