like C file, add reference in a SQL script file at beginning?
#include "somefile.sql"
-- other code...
If your scripts are . sql (or any kind of text) file, as @Abe Miesller says (upvoted) you can run them from within SSMS via the :r command, when SQLCMD mode is enabled. You would have to know and script the exact file path and name. This cannot be done from within a stored procedure.
ApexSQL Compare offers integration for SSMS and Visual Studio, so you can right-click a SQL object in Object Explorer, select the Compare scripts in the right-click context menu, then Set as left/right, and the New comparison query window will be shown.
If you are running them with sqlcmd you can use r:
to include other scripts
:r C:\Files\selectFromTable.sql
Editing SQLCMD Scripts in the Transact-SQL Editor
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With