SQL Server Is there a better way to keep Stored procedures in sync across databases that is also easy and can be done within Visual Studio?

toiithl6  于 11个月前  发布在  其他
关注(0)|答案(2)|浏览(100)

The code is in sync because I am in charge of that aspect (its just xcopying to the different servers when I need to)

The DB people are incharge of keeping the SPs in sync and right now that is asking them to manually do a ALTER PROCEDURE on a specific DB.

Is there some easy way to do this in Visusal Studio?

Id love to have a DB project in VS and be able to just push a button and that would goto every DB server in some config file and make sure they all match..

something like that?

holgip5t

holgip5t1#

Yes, it is possible to keep objects in synch with a single button click from Visual Studio. This is done by calling the Red Gate SQL Compare command line from VS if you add an entry in Tools/External Tools

Of course you'll need to install SQL Compare first.

And then set up the following External Tool (this example copies a stored procedure from a dev database to a test database):

  • Title: Sync selected stored procedure
  • Command: c:\Program Files\Red Gate\SQL Compare 8\SQLCompare.exe
  • Arguments: /s1:.\sql2005 /db1:DevDB /s2:.\sql2005 /db2:TestDB /include:StoredProcedure:[$(CurText)] /synchronize
  • Check the "Use Output window" so you can see what's going on.

This will add an item under the Tools menu. You can also add this as a button in the toolbar.

To use this, select the text of the stored procedure you wish to synchronize and go to Tools/Synch selected stored procedure. This will synchronize the selected procedure. The drawback is that the above example is a one-to-one synchronization. If you have a number of target servers, you'll have to wrap multiple statements in a batch file and call the sqlcompare.exe command line a number of times. An of course the above 'External Tool' would need to call the batch file and pass the parameter to the batch file.

Of course this solution assumes that you've applied your stored procedure to a development database. Is this how you work? Or are you trying to synchronize from a script that belongs to your VS project?

xsuvu9jc

xsuvu9jc2#

We use redgate's suite of tools to do this. I don't work there but I sure love the tools. VS also has a DB compare tool if you get the VSTS or DB edition. Not sure if it lets you sync them or not but would give you some ammo to show your boss the problem.

相关问题