A very common question I often see users not sure about the answer. This is indeed a tricky question, but a very simple one. If I am the interviewer, I may ask this question to the user, but if they do not know the answer of this question, I would not give any negative remarks to interviewee. I think it is even old school to even ask these kind of questions. It has been long since I have stopped asking this question, once in a while, I still see this question being asked by my fellow colleagues. Well, let us revisit the age old question again about the fastest way to display code of any stored procedure.
Question: What is the fastest way to display code of any stored procedure?
Answer: Well, you may be temped to say that the fastest way is to go to stored procedure in SQL Server Management Studio and click on modify. Honestly, this may be right answer if you have very few stored procedures in your database. However, if you have hundreds of the stored procedure in your application, trust me it is not possible to have located your stored procedure easily (even if you use the search feature of SQL Server Management Studio).
Let us see the fastest way to display code of the SP.
First, go to SQL Server Management Studio and select option Results to Text (shortcut CTRL+T).
Next type following script in Query Editor and hit execute. Do not forget to replace the string ‘NameofYourSP’ with the name of your actual stored procedure.
You will see immediate results in the query window in the text format. Trust me, once you get used to this method you will find it very easy to display the code of the SP.
Reference: Pinal Dave (https://blog.sqlauthority.com)