Click here to Skip to main content
15,894,291 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I just want to get the tables and their corresponding columns which are written as a part of stored procedure using t-sql? How can I get a list of the same? Can anyone help me? Thanks
Posted
Comments
Kornfeld Eliyahu Peter 25-Feb-14 2:58am    
Have you done anything so far? Show some effort (code or searching)! As is it ain't a question...
King Fisher 25-Feb-14 8:09am    
not clear.
Tomas Takac 25-Feb-14 15:45pm    
This took about 30s to find: http://technet.microsoft.com/en-us/library/ms345404.aspx
♥…ЯҠ…♥ 25-Feb-14 23:17pm    
Good one,it should be in the solution section ;-)

Have a look here: List columns and attributes for every table in a SQL Server database[^]
Please, do not afraid to use Google[^]!
 
Share this answer
 
Hello guys, I tried following effort to get my query resolved.


SQL
SELECT distinct sp.name as StoredProc, tbl.name AS [Table], col.name AS [Column]
FROM sysobjects sp
INNER JOIN sysdepends sd ON sp.id = sd.id
INNER JOIN sysobjects tbl ON tbl.id = sd.depid
INNER JOIN syscolumns col ON col.colid = sd.depnumber AND col.id = sd.depid
WHERE sp.name IN ( SELECT name FROM sysobjects WHERE id IN(SELECT id from syscomments WHERE text LIKE '%passParamToGetYourSPs_%'))
--group BY sp.name
--AND sp.name = 'Search_SP_Name'
ORDER BY sp.name, tbl.name, col.name


Thanks for all your efforts. :)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900