I\'m really struggling with the best approach for managing a SQL Azure database which is based on a Visual Studio 2010 Database Project. I figured it would be easy enough to use
A simple command line tool that replaces invalid SQL Azure statements is all that is needed:
private const string STARTPLACEHOLDER = "AZURESCRIPTSTARTPLACEHOLDER";
public static void Do(string fileName)
{
// Read the original file
StringBuilder script = new StringBuilder();
using (StreamReader reader = new StreamReader(fileName))
{
script.Append(reader.ReadToEnd());
}
// Remove everything before the start placeholder
int startPlaceHolder = script.ToString().IndexOf(STARTPLACEHOLDER, 0);
if (startPlaceHolder > 0)
{
script.Remove(0, startPlaceHolder + STARTPLACEHOLDER.Length);
}
// Remove WITH clause
script.Replace("WITH (ALLOW_PAGE_LOCKS = ON, ALLOW_ROW_LOCKS = ON, PAD_INDEX = OFF, IGNORE_DUP_KEY = OFF, STATISTICS_NORECOMPUTE = OFF)", string.Empty);
// Create azure compatible output file
using (StreamWriter writer = new StreamWriter(Path.Combine(Path.GetDirectoryName(fileName), Path.GetFileNameWithoutExtension(fileName) + "_Azure" + Path.GetExtension(fileName))))
{
writer.Write(script.ToString());
}
}