Link to home
Start Free TrialLog in
Avatar of mj_cole
mj_cole

asked on

Ability to export the sql behind a SP / view / query to an ascii file ?

Is there a way that I can export the SQL behind a stored procedure or view, into a text file, or preferably into a recordset string field.

My absolute ideal would to have a stored procedure that returns a recordset with the database object name and the SQL in the object, be it a stored procedure or a view, that I can use to get ascii copies of all my db objects, such that I can see their progress over time in CVS.

Any ideas ?

Regards
Marts
SOLUTION
Avatar of arbert
arbert

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of arbert
arbert

You can also write queries against the information.schema_views (located in the master database) to retrieve information....

Brett
Avatar of mj_cole

ASKER

sp_helptext  seems to do the job :)

is there a master SP to return all the stored procedures and views, such that I can then write my own SP to get the list and then call sp_helptext on that list ?

Regards
Marts

ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Scott Pletcher
Actually I think the information_schema views only return the first 4K of object text, so it's not a safe way to get the source.  You really need to use sp_helptext.