Q:

I am getting max depth exceeded while building the docker image for Microsoft SQL stored procedure

Step 115/172 : 
RUN Invoke-Sqlcmd -ServerInstance localhost -Database MY_DB -InputFile 'c:\tmp\sql_scripts\dbo.usp_InsertUpdateSSearchDateTimeFilter.sql'
---> Running in 977b55fecdfc

Error:

Max depth exceeded

A:

This happens because your Dockerfile has exceeded the 125 layers limit for docker images.
If you add the Dockerfile to the question I can help you to simplify it. As a first suggestion, try to group commands in only one RUN

