SQL Server function to get directory of a .sql file from inside the file

Viewed 22

I am working with SQL Server 2019. I have a abc_list_codes.sql which has bunch of SQL statements. This file is stored in c:\project_abc\sql\list folder. I can open SQL Server Management Studio, then open a New Query tab against a database, then open this abc_list_codes.sql file and run it successfully.

Now I want to show the directory of that file when that file is run in SQL Server Management Studio. Is there a function or a way in SQL that I can write in abc_list_codes.sql, so when I run it in SQL Server Management Studio, it will return c:\project_abc\sql\list as output?

0 Answers
Related