Catching specific statements using new MI008 “Statement used” rule

sqlcodeguard, 2015-11-05 (first published: 2015-10-30)

Imagine that you want (for some reason) prohibit usage of some statement (or statements), eg – CURSOR
How can you find if this statement is used in the script? To perform this task you should use newly added rule MI008 “Statement used”

First you must mark this rule as “Warning” on the “Issues” tab of settings window

Second – you must specify which statement you want to catch.
Each statement (and event most parts of statement) can be identified by tag. Full list of tag is pretty big and I’m not yet ready to publish it. But here are some of tags:
CREATE INDEX: index-statement
DROP INDEX: drop-index
CREATE TABLE: create-statement-table
DROP TABLE: drop-table
TRUNCATE TABLE: truncate-table
DECLARE CURSOR: cursor-declaration
If you need more tags please contact me, i’ll help you.

Ok, imagine that you want to catch  DECLARE CURSOR and CREATE TABLE statements
You need to add appropriate tags to MI008 Statements list on “Options” tab of Settings window, one tag per line.

Now you can process script or database to find if statements you find is really used.
Column “Additional info” of issues list will contain tag of found statement.

That’s all, folks!
Have fun!





Related content

Database Mirroring FAQ: Can a 2008 SQL instance be used as the witness for a 2005 database mirroring setup?

Question: Can a 2008 SQL instance be used as the witness for a 2005 database mirroring setup? This question was sent to me via email. My reply follows. Can a 2008 SQL instance be used as the witness for a 2005 database mirroring setup? Databases to be mirrored are currently running on 2005 SQL instances but will be upgraded to 2008 SQL in the near future.

Robert Davis


1,567 reads

Networking – Part 4

You may want to read Part 1 , Part 2 , and Part 3 before continuing. This time around I’d like to talk about social networking. We’ll start with social networking. Facebook, MySpace, and Twitter are all good examples of using technology to let…

Andy Warren


1,530 reads

Speaking at Community Events – More Thoughts

Last week I posted Speaking at Community Events – Time to Raise the Bar?, a first cut at talking about to what degree we should require experience for speakers at events like SQLSaturday as well as when it might be appropriate to add additional focus/limitations on the presentations that are accepted. I’ve got a few more thoughts on the topic this week, and I look forward to your comments.

Andy Warren


360 reads