Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8632883
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T09:24:45+00:00 2026-06-12T09:24:45+00:00

Possible Duplicate: Constants and Include files in TSQL I’ve been looking for a T-SQL

  • 0

Possible Duplicate:
Constants and Include files in TSQL

I’ve been looking for a T-SQL equivalent of the C “#include” directive. As I haven’t found, I wonder

  • Is it possible that MS did not include any sort of SQL files inclusion / joined execution
  • If not, why
  • If not, is there any better way for me to execute several SQL files at once without copy-paste or manual precompilation

For those curious of my motivations, I am writing a set of similar queries, and I find it convenient to externalize constants (from enum tables), pre-computations (making some test input tables) and parameter variables (which subsets I’m working on).

As far as I know, I can’t really use stored procedures or functions for that (And I don’t like the idea of polluting my DB with those).

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T09:24:46+00:00Added an answer on June 12, 2026 at 9:24 am

    You could look into executing in SQLCMD mode, either in SSMS or via sqlcmd utility (command line). There is a :r <file name> command that allows you to include external files in the current execution session. So if you included a :r my_init_script.sql near the top of your larger script it may achieve what you are after.

    Note, this is for SQL 2005 and up.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: Where are the request method constants in the Servlet API? I'm looking
Possible Duplicate: Avoiding repeated constants in CSS I want to include a class within
Possible Duplicate: Objective C defining UIColor constants I'd like to use few colours throughout
Possible Duplicate: How do I recursively delete a directory and its entire contents (files+sub
Possible Duplicate: Modifying C string constants? As far as I understand if you want
Possible Duplicate: C# naming convention for constants? I'm refactoring a library in C# and
Possible Duplicate: Understanding Enums in Java Why should we use enums rather Java constants?
Possible Duplicate: When to use std::size_t? I have a lot of constants in my
Possible Duplicate: Modifying C string constants? Pointer to const char vs char array vs
Possible Duplicate: C/C++: Optimization of pointers to string constants Suppose you have a string

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.