Please start any new threads on our new site at We've got lots of great SQL Server experts to answer whatever question you can come up with.

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
Save Password
Forgot your Password?

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Reusable blocks of code in stored procedures
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Starting Member

1 Posts

Posted - 04/15/2008 :  10:13:17  Show Profile  Reply with Quote
I have several stored procedures with a similar query. The SELECT clauses are identical, but the FROM and WHERE clauses are different.

Since the SELECT clause is long and complicated (and often changes), I want to place the SELECT clause in a separate file and then have the stored procedures include the block of text for the SELECT clause when they compile.

Is this possible? Looking through the docs and searching online, I don't see any way to do this.

Very Important crosS Applying yaK Herder

52326 Posts

Posted - 04/15/2008 :  11:32:07  Show Profile  Reply with Quote
I think what you require are User Defined Functions where you can put your common code and them call them wherever you need to include them. But before that can you post your sample code so as to give us more idea on this.
Go to Top of Page
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.02 seconds. Powered By: Snitz Forums 2000