I am new to SQL Server. I am logged into my database through SQL Server Management Studio.
I have a list of stored procedures. How do I view the stored procedure code?
The other answers that recommend using the object explorer and scripting the stored procedure to a new query editor window and the other queries are solid options.
I personally like using the below query to retrieve the stored procedure definition/code in a single row (I'm using Microsoft SQL Server 2014, but looks like this should work with SQL Server 2008 and up)
SELECT definition
FROM sys.sql_modules
WHERE object_id = OBJECT_ID('yourSchemaName.yourStoredProcedureName')
More info on sys.sql_modules:
https://docs.microsoft.com/en-us/sql/relational-databases/system-catalog-views/sys-sql-modules-transact-sql