Discussion:
SSE2008 T-SQL: Include Files?
(too old to reply)
Gene Wirchenko
2012-09-10 23:10:59 UTC
Permalink
Dear SQLers:

Does SQL Server (and especially SSE2008) have the concept of
include files? (I have been unable to find anything, but I could
really use this.) If it does, a pointer to how to use it, please.

I find that I am repeating a lot of error handling code and
because of the limitations of the language (having to execute the
creation and insertion to on a temporary table all in the same SP), I
have to repeat code. I very much doubt that I will never have to
change this code, and when I do, I want it to be changed everywhere I
have written it.

Failing that, I will have to put together a preprocessor. I
would rather not.

Sincerely,

Gene Wirchenko
rpresser
2012-09-11 20:02:26 UTC
Permalink
Post by Gene Wirchenko
Does SQL Server (and especially SSE2008) have the concept of
include files? (I have been unable to find anything, but I could
really use this.) If it does, a pointer to how to use it, please.
Sorry. It doesn't, other than invoking stored procedures or declared functions.
Post by Gene Wirchenko
Failing that, I will have to put together a preprocessor. I
would rather not.
m4 should be adequate.
Erland Sommarskog
2012-09-11 21:17:07 UTC
Permalink
Post by Gene Wirchenko
Does SQL Server (and especially SSE2008) have the concept of
include files?
SQL Server does not have the concept of files. This is a server product.

You could try SQLCMD mode in SSMS. SQLCMD has ~r to read in a file, but I
would not like to maintain that code. But read about SQLCMD in Books Online.
Post by Gene Wirchenko
I find that I am repeating a lot of error handling code and
I warned you, didn't I?
--
Erland Sommarskog, SQL Server MVP, ***@sommarskog.se

Links for SQL Server Books Online:
SQL 2008: http://msdn.microsoft.com/en-us/sqlserver/cc514207.aspx
SQL 2005: http://msdn.microsoft.com/en-us/sqlserver/bb895970.aspx
Loading...