I am working on SDL Server 2008 R2, where I generated a schema-only database script. The generated script is as follows:
ALTER TABLE [dbo].[ConsoleServer] WITH CHECK ADD CONSTRAINT [FK_ConsoleServer_RackUnits] FOREIGN KEY([RackUnitID])
REFERENCES [dbo].[RackUnits] ([UnitID])
GO
ALTER TABLE [dbo].[ConsoleServer] CHECK CONSTRAINT [FK_ConsoleServer_RackUnits]
I have these 2 questions:-
I know that the first line is responsible to create a FK between two DB tables. but what is the purpose of the following :
ALTER TABLE [dbo].[ConsoleServer] CHECK CONSTRAINT [FK_ConsoleServer_RackUnits]
In general, why does the DB script have the word
GO
. Now if I remove it the script will be executed well on the destination DB, so why it is included in the script prior to any statement?