question

melgoth avatar image
melgoth asked

retrieve full path of a loaded script file inside the script file

Hi all! I’m looking for a solution to retrieve the path of a script file when it’s loaded in SSMS. I need this info to set a variable so I can include sub script files from a main script file. The mechanics to include files in a script file is described in [ http://www.sqlservercentral.com/articles/sqlcmd+mode/129764/][1] but in this example the path is hardcoded, which isn’t possible to use in my environments. To retrieve the full path from a script file is described in [ https://sqlstudies.com/2017/04/24/ssms-tips-copy-full-path/][2]. So now I need to retrieve this full path value inside the script file, maybe there exists a environment variable or another access method to SSMS which I can use inside the script file. [1]: http://www.sqlservercentral.com/articles/sqlcmd+mode/129764/ [2]: https://sqlstudies.com/2017/04/24/ssms-tips-copy-full-path/
script-task
10 |1200 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

0 Answers

· Write an Answer

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.