1

In other computing languages, you can call other methods or subroutines within a method or subroutine.

In VBA:

Public Sub x()
   Call y
End Sub
Private Sub y()
   Debug.Print "Hello World!"
End Sub

Can you do this in SQL?

Declare @FilePath as VarChar(Max)

Set @FilePath = '\\SomeServerExtension\MyFile.sql'

Execute @FilePath

It would save space and make the query appear cleaner.

delavepr
  • 31
  • 4

1 Answers1

0

You can EXEC other stored procedures from a stored procedure. You cannot execute arbitrary files (fortunately), even if the server could access them. It'd be a security nightmare, frankly.

Jeroen Mostert
  • 27,176
  • 2
  • 52
  • 85