Questions tagged [scriptdom]

The Microsoft.SqlServer.TransactSql.ScriptDom namespace provides Microsoft SQL Server-specific Parser and Script Generator support.

23 questions
4
votes
1 answer

ScriptDom parsing of SELECT with alias

I'm looking to use ScriptDom to parse T-SQL statement and ensure that at least two columns are specified. I found a way to extract the column names and can properly do my validation from that. However I also want to validate if the column was…
Newton
  • 187
  • 7
3
votes
1 answer

Microsoft.Data.Schema.ScriptDom.Sql dll/namespace missing in vs 2013

Is there a way to get the namespace Microsoft.Data.Schema.ScriptDom.Sql added to vs 2013, I searched and found that the earlier Microsoft.Data.Schema.ScriptDom has been superseded with TransactSql.ScriptDom but I can't find a way to include the…
Tom
  • 125
  • 1
  • 11
3
votes
1 answer

Parsing out complete dynamic SQL expressions from hundreds of stored procedures

I've inherited a large application that has many hundreds of stored procedures, many of which use dynamic SQL. In order to get a better handle of the types of SQL I am dealing with, it would be extremely useful if I had a way to parse the query text…
tbone
  • 5,715
  • 20
  • 87
  • 134
3
votes
2 answers

How to extract cross databases references using scriptdom API

Microsoft has exposed the scriptdom API to parse and generate TSQL. I'm new to it and still playing with it. I want to know how to get the cross databases references from queries like this one. UPDATE t3 SET description = 'abc' FROM …
Just a learner
  • 26,690
  • 50
  • 155
  • 234
2
votes
1 answer

Which API in the Microsoft Tsql Scriptdom will allow me to retrieve/store ALL table references from a SQL script?

Here is the MS doc that I am referencing: https://learn.microsoft.com/en-us/dotnet/api/microsoft.sqlserver.transactsql.scriptdom?view=sql-dacfx-140.3881.1 I have looked through this several times already, but can not seem to find where I am able to…
Data Dill
  • 353
  • 4
  • 14
2
votes
1 answer

Generate a Query using Microsoft.SqlServer.TransactSql.ScriptDom

It seems ScriptDom has a complex architecture. Since there is no documentation about ScriptDom, do you know how can generate a joined query like this using ScriptDom types? SELECT c.Title as ColumnTitle, t.Title as TableTitle, o.Title as OwnerTitle…
Jalal
  • 6,594
  • 9
  • 63
  • 100
1
vote
1 answer

TSql130Parser seems not to recognize hints

I created the following console application with a reference to Microsoft.SqlServer.TransactSql.ScriptDom.dll: Imports Microsoft.SqlServer.TransactSql.ScriptDom Imports System.IO Module Module1 Sub Main() Dim sql = "SELECT * FROM…
Alex
  • 419
  • 1
  • 5
  • 14
1
vote
1 answer

ScriptDom + DeleteStatement

I want to insert "DeleteStatement" after any "DeclareTableVariableStatement" but I don't know how! it's my sample code. public override void Visit(StatementList node) { foreach (DeclareTableVariableStatement declareTableVariableStatement in…
1
vote
3 answers

SQL Server ScriptDom Parsing

The team of developers I work with are using SQL Data Projects for a large piece of work we have to do against an existing database. We are a few weeks in and there have been a few gotchas, but the experience has been generally good. However, when…
1
vote
1 answer

How to detect if column in SELECT can be null?

I'm using DacFx at design-time to create a C# data layer that is generated from the sql files in an SSDT database project. See my SqlSharpener project on Github to see what I'm talking about. I'm generating DTO objects that represent a row coming…
adam0101
  • 29,096
  • 21
  • 96
  • 174
0
votes
1 answer

Option in ScriptDom to retrieve table names with join column names?

Would like to create analysis for queries in SQL Server which will be checking which tables were join on which tables on which columns. Would like to use ScriptDom in C#. For example we have query: SELECT * FROM tabel1 INNER JOIN tabel2 ON…
adam.g
  • 101
  • 3
0
votes
1 answer

How to find error on script using Microsoft.SqlServer.TransactSql.ScriptDom

I have a SQL script X Select top 1 * from table. I use MicrosoftSql.Smo to check script has error or not. The letter X is incorrect for SQL script. But it cannot find the error in the script and evaluates as true. How can I solve this problem.…
beetlejuice
  • 115
  • 1
  • 10
0
votes
1 answer

In Dynamic SQL, ScriptDom is finding IF statements, but not UPDATE statements

I'm using TransactSQL.ScriptDom to parse SQL statements. I have rules defined where I want to find a) IF statements and b) UPDATE statements. When I'm looking through non-dynamic SQL, the rules work just fine. However, when I'm looking through…
WEFX
  • 8,298
  • 8
  • 66
  • 102
0
votes
1 answer

Multipart identifiers in Microsoft.SqlServer.TransactSql.ScriptDom that are not tables

I'm trying to use Microsoft.SqlServer.TransactSql.ScriptDom to check that an expression is a scalar constant. Here is such an expression: DATEADD(YEAR, -21, CURRENT_TIMESTAMP) Here is not such an expression: DATEADD(YEAR, -21, DateOfBirth) It is…
Richard Barraclough
  • 2,625
  • 3
  • 36
  • 54
0
votes
0 answers

Why does Microsoft.SqlServer.TransactSql.ScriptDom.TSqlParser fail to parse a simple valid expression?

We are using Microsoft.SqlServer.TransactSql.ScriptDom heavily to process some SQL scripts. Our understanding is that the parser is supposed to be full fidelity. However, we recently found this bug: using…
Clement
  • 3,990
  • 4
  • 43
  • 44
1
2