The development team I'm working with is using SQL Data Projects for the great work that we have to do against an existing database. We went through several weeks and there were several mistakes, but the experience was generally good.
However, when we connect to production, the dba team refuses to accept DACPAC as a deployment method. Instead, they want to see a traditional script for each DML or DDL statement.
Current thinking is to create a script difference between the finished SQL project and the production environment, and then parse this into separate scripts. I donβt know well.
To parse the difference script two options are possible:
- Parse the script based on the batch separator command, GO. Pretty simple solutions, but promise.
- Or use Microsoft.SqlServer.TransactSql.ScriptDom. It looks more promising, but it seems much more complicated.
I'm currently testing ScriptDom, but it's hard for me to figure this out. My current, but not only problems, are as follows.
I am trying to parse the following SQL using ScriptDOM in C #:
CREATE TABLE dbo.MyTable
(
MyColumn VARCHAR(255)
)
But I donβt see how to access the VARCHAR size, in this case 255.
The code I use is as follows:
TSqlFragment sqlFragment = parser.Parse(textReader, out errors);
SQLVisitor myVisitor = new SQLVisitor();
sqlFragment.Accept(myVisitor);
public override void ExplicitVisit(CreateTableStatement node)
{
}
From each column definition, I expected to find a length property or the like. However, I also have a suspicion that you might use the visitor template I come across to re-analyze each column definition. Any ideas?