Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
Log in  ::  Register  ::  Not logged in

Get your favorite SSC scripts directly in SSMS with the free SQL Scripts addin. Search for scripts directly from SSMS, and instantly access any saved scripts in your SSC briefcase from the favorites tab.
Download now (direct download link)

Synchronize a function between two servers

By Th Tr,

This script is the same method with spSynchStoredProcedure but used for views.

To run this stored procedure, you need to create two linked servers for your source server and your target server. You can create them in local SQL Server and then run this to synchronize.

For example, your development server is called DEV and your production server is called PROD, and you create two linked servers in local SQL Server with the same name. Assumed that your database between DEV and PROD have the same name: TestDB.

This procedure may be useful if your function is not over 4000 characters. If it's over 4000 characters, you have to modify it a little.

If you want to synchronize a function called TestFunc between TestDB of DEV and PROD, you can excute like that:

EXEC dbo.spSynchFunction @FunctionName = 'TestFunc', @SourceServer = 'DEV', @SourceDatabase = 'TestDB', @TargetServer = 'PROD', @TargetDatabase = 'TestDB'


Total article views: 560 | Views in the last 30 days: 2
Related Articles

The concurrent snapshot for publication 'TESTDB' is not available

The concurrent snapshot for publication 'TESTDB' is not available because it has not been fully gene...


Create server side trace.

Cannot create server side trace - error 12


To create login in many servers.

To create login in many servers.


Creating SQL Server 2000 Virtual Directories

Creating IIS SQL Server 2000 Virtual Directories


error when creating the link server

error when creating the link server


Join the most active online SQL Server Community

SQL knowledge, delivered daily, free:

Email address:  

You make SSC a better place

As a member of SQLServerCentral, you get free access to loads of fresh content: thousands of articles and SQL scripts, a library of free eBooks, a weekly database news roundup, a great Q & A platform… And it’s our huge, buzzing community of SQL Server Professionals that makes it such a success.

Join us!

Steve Jones

Already a member? Jump in:

Email address:   Password:   Remember me: Forgotten your password?
Steve Jones