views:

60

answers:

2

Hello!

I'm in the process to migrate a datebase. New is that a part of the data's home is in an external database (ERP-System). I have to modify a large number of queries.

How can i check all queries & SP's, if they still run successfuly?

If i have a query 'A' which depends on query 'B', and i change a column in query 'B' i do not get the error until i run query 'A'. Is there a way to check all queries systematicaly for binding errors?

We'r running MS-SQL 2008

A: 

I would solve this by writing unit tests for my application, focusing initially on all of the methods that use the external database.

RedFilter
+1  A: 

finally i came up with this script. it generates a 'select * from' for each query and with SHOWPLAN_TEXT ON it emits just the plan or an error if the query is broken.

Use it like this: Execute the query below with output to text enabled. Copy the generated text in a new query an execute it.

SET NOCOUNT ON
GO

PRINT 'SET SHOWPLAN_TEXT ON'
PRINT 'GO'
SELECT  'SELECT * FROM [' + sys.schemas.name + '].[' + sys.objects.name + ']' AS [--stmt]
FROM         sys.objects INNER JOIN
                      sys.schemas ON sys.objects.schema_id = sys.schemas.schema_id
WHERE     (sys.objects.type = 'V')
PRINT 'GO'
PRINT 'SET SHOWPLAN_TEXT OFF'
PRINT 'GO'
Fabian