Skip to content

Commit

Permalink
Use OBJECT_ID to check for table. Specify Schema when checking. Add G…
Browse files Browse the repository at this point in the history
…O statements. (#14)
  • Loading branch information
jadarnel27 authored Dec 26, 2018
1 parent 06b0bc1 commit d4c1eaf
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/GetSqlServerVersionInfo/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ private static string BuildSqlScript(List<SqlServerBuild> builds)
{
var sqlScript = new StringBuilder();
sqlScript.AppendLine(@"
IF NOT EXISTS (SELECT NULL FROM sys.tables WHERE [name] = 'SqlServerVersions')
IF (OBJECT_ID('dbo.SqlServerVersions') IS NULL)
BEGIN
CREATE TABLE dbo.SqlServerVersions
Expand All @@ -218,6 +218,7 @@ ReleaseDate ASC
);
END;
GO
DELETE dbo.SqlServerVersions;"
);
Expand All @@ -233,7 +234,9 @@ INSERT INTO dbo.SqlServerVersions
}
// Remove the trailing comma
sqlScript.Remove(sqlScript.Length - 1, 1);
sqlScript.Append(';');
sqlScript.Append(@"
;
GO");

return sqlScript.ToString();
}
Expand Down

0 comments on commit d4c1eaf

Please sign in to comment.