Its throws an exception when I try to execute this
if not exists (select * from dbo.sysobjects where id = object_id(N'{databaseOwner}[{objectQualifier}Telekom_Xtree]') and OBJECTPROPERTY(id, N'IsTable') = 1)
BEGIN
CREATE TABLE {databaseOwner}[{objectQualifier}Telekom_Xtree]
(
[ModuleID] [int] NOT NULL,
[ItemID] [int] NOT NULL IDENTITY(1, 1),
[Content] [ntext] NOT NULL,
[CreatedByUser] [int] NOT NULL,
[CreatedDate] [datetime] NOT NULL
)
ALTER TABLE {databaseOwner}[{objectQualifier}Telekom_Xtree] ADD CONSTRAINT [PK_{objectQualifier}Telekom_Xtree] PRIMARY KEY CLUSTERED ([ItemID])
CREATE NONCLUSTERED INDEX [IX_{objectQualifier}Telekom_Xtree] ON {databaseOwner}[{objectQualifier}Telekom_Xtree] ([ModuleID])
ALTER TABLE {databaseOwner}[{objectQualifier}Telekom_Xtree] WITH NOCHECK ADD CONSTRAINT [FK_{objectQualifier}Telekom_Xtree_{objectQualifier}Modules] FOREIGN KEY ([ModuleID]) REFERENCES {databaseOwner}[{objectQualifier}Modules] ([ModuleID]) ON DELETE CASCADE NOT FOR REPLICATION
END
GO
System.Data.SqlClient.SqlException: Incorrect syntax near 'GO'. at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection) at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) at System.Data.SqlClient.SqlCommand.RunExecuteNonQueryTds(String methodName, Boolean async) at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(DbAsyncResult result, String methodName, Boolean sendToPipe) at System.Data.SqlClient.SqlCommand.ExecuteNonQuery() at Microsoft.ApplicationBlocks.Data.SqlHelper.ExecuteNonQuery(SqlConnection connection, CommandType commandType, String commandText, SqlParameter[] commandParameters) at Microsoft.ApplicationBlocks.Data.SqlHelper.ExecuteNonQuery(String connectionString, CommandType commandType, String commandText, SqlParameter[] commandParameters) at Microsoft.ApplicationBlocks.Data.SqlHelper.ExecuteNonQuery(String connectionString, CommandType commandType, String commandText) at DotNetNuke.Data.SqlDataProvider.ExecuteScript(String Script, Boolean UseTransactions) if not exists (select * from dbo.sysobjects where id = object_id(N'dbo.[Telekom_Xtree]') and OBJECTPROPERTY(id, N'IsTable') = 1) BEGIN CREATE TABLE dbo.[Telekom_Xtree] ( [ModuleID] [int] NOT NULL, [ItemID] [int] NOT NULL IDENTITY(1, 1), [Content] [ntext] NOT NULL, [CreatedByUser] [int] NOT NULL, [CreatedDate] [datetime] NOT NULL ) ALTER TABLE dbo.[Telekom_Xtree] ADD CONSTRAINT [PK_Telekom_Xtree] PRIMARY KEY CLUSTERED ([ItemID]) CREATE NONCLUSTERED INDEX [IX_Telekom_Xtree] ON dbo.[Telekom_Xtree] ([ModuleID]) ALTER TABLE dbo.[Telekom_Xtree] WITH NOCHECK ADD CONSTRAINT [FK_Telekom_Xtree_Modules] FOREIGN KEY ([ModuleID]) REFERENCES dbo.[Modules] ([ModuleID]) ON DELETE CASCADE NOT FOR REPLICATION END GO