SQL Clone
SQLServerCentral is supported by Redgate
Log in  ::  Register  ::  Not logged in

Catching specific statements using new MI008 "Statement used" rule

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!


Leave a comment on the original post [sqlcodeguard.blogspot.com, opens in a new window]

Loading comments...