April 10, 2015 at 7:07 am
maurer.martina (4/10/2015)
allowed characters between "delete" and "from" and "myTable" are only blanks, right?
No. To start with, the FROM is optional
Valid (but that your replace won't pick up)
DELETE[MyTable];
DELETE
FROM
[MyTable];
And one it will, but which isn't a delete
Insert [MyTable] -- Don't delete from MyTable!!!!!!! It will break the application
select Null, 1, 2, 3
To do what you want completely, you'll need to re-implement the T-SQL Parser. It's a very hard language to parse, even if you're familiar with writing parsers and compilers. iirc MS did release a DLL with a parser for a subset of T-SQL, can't remember details though
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
April 10, 2015 at 7:50 am
I see, there is no short way...
30 years ago I write a cobol-parser in 6 weeks in programming langage "turbo pascal". But cobol was/is an easy language, and I was young and a nerd. Now I am 55 and I have family 😉
And I am not familiar in coding with T-SQL (or C#)
But maybe there is a TSQL-Nerd out there? Sometimes, wonder happens...
April 10, 2015 at 8:07 am
maurer.martina (4/10/2015)
I see, there is no short way...30 years ago I write a cobol-parser in 6 weeks in programming langage "turbo pascal". But cobol was/is an easy language, and I was young and a nerd. Now I am 55 and I have family 😉
And I am not familiar in coding with T-SQL (or C#)
But maybe there is a TSQL-Nerd out there? Sometimes, wonder happens...
You have a whole group of t-sql nerds telling you not to do this because it is entirely too difficult to get it right.
_______________________________________________________________
Need help? Help us help you.
Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.
Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/
April 10, 2015 at 8:14 am
maurer.martina (4/10/2015)
But maybe there is a TSQL-Nerd out there? Sometimes, wonder happens...
I tried once to write a parser for MS Access SQL. After 3 months (and I was doing it as part of my job, so that's 3 months almost full time) with the parser not even handling subqueries, nor insert, update, delete, I gave up.
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
April 10, 2015 at 9:09 am
I've used the Microsoft.SqlServer.SqlParser.SqlCodeDom.SqlScript object to create a parser that found all the objects in a given query, so that i could format the whitespace to my own rules.
it's a freaking lot of work;
i'm a damn good developer as well, and familiar with parsing as well, and it'd take me a while to build something like that, just to have it return UsesSelect/UsesInsert/UsesUpdate kind of data.
i don't see the value in the end results. nice to know, but you could "see" it faster just by reading the code if the procedure.
Lowell
Viewing 5 posts - 16 through 19 (of 19 total)
You must be logged in to reply to this topic. Login to reply