Yes. My earlier advice is part of that solution.
Suppose you have a procedure that looks like this...
Code:
[COLOR=blue]Create[/color] [COLOR=blue]Procedure[/color] GetCustomerOrderCount
[COLOR=blue]As[/color]
[COLOR=blue]Select[/color] CustomerName, [COLOR=#FF00FF]Coalesce[/color]([COLOR=#FF00FF]Count[/color](*), 0) [COLOR=blue]As[/color] OrderCount
[COLOR=blue]From[/color] Customer
[COLOR=#FF00FF]Left[/color] [COLOR=blue]Join[/color] Orders
[COLOR=blue]On[/color] Customer.CustomerId = Orders.CustomerId
[COLOR=blue]Group[/color] [COLOR=blue]By[/color] CustomerName
In VB, you can first execute this query.
Code:
[COLOR=blue]If[/color] Exists([COLOR=blue]Select[/color] * [COLOR=blue]From[/color] Information_Schema.Routines [COLOR=blue]Where[/color] Specific_Name = [COLOR=red]'GetCustomerOrderCount'[/color])
[COLOR=blue]Drop[/color] [COLOR=blue]Procedure[/color] GetCustomerOrderCount
And then execute the Create Procedure query. Essentially, if the procedure exists, you can drop it. Then, simply create it.
Usually what I do is... I have a table in the database called CONFIG. This table looks like...
Code:
[COLOR=blue]Create[/color] [COLOR=blue]Table[/color] Config(ConfigName [COLOR=blue]VarChar[/color](50) [COLOR=blue]Primary[/color] [COLOR=blue]Key[/color], ConfigValue [COLOR=blue]VarChar[/color](200))
In this table, I will have a record that looks like...
[tt][blue]
ConfigName ConfigValue
--------------- -----------
DatabaseVersion 23
[/blue][/tt]
When my app starts up, it compares the value in the table with the value hard coded in the app. If the version (in the database) is less, then I run the scripts (which may take a couple minutes). If the version is the same, I don't do anything. You see, it's VERY quick to see if the database version is the same (or not), so it doesn't slow down my load process. Only if the versions are different will I actually update the procedures (and tables, views, functions, etc...).
Make sense?
-George
Strong and bitter words indicate a weak cause. - Fortune cookie wisdom