2

I'm wondering if anyone knows of a way to (from C#) retrieve the SQL statement that created a specific View, Stored Procedure, Function etc. on a MSSQL server?

UPDATE:

The suggestion by R. Richards, using "sp_helptext" was what I was looking for. I wasn't aware of this procedure, thanks :)

Aidal
  • 799
  • 4
  • 8
  • 33
  • take a look here: (http://stackoverflow.com/questions/6215459/t-sql-query-to-show-table-definition) and here (https://dba.stackexchange.com/questions/95262/get-object-script-in-sql-server-via-t-sql) – Rigerta Apr 24 '17 at 11:01
  • You could consider using [SMO Scripter](https://learn.microsoft.com/en-us/sql/relational-databases/server-management-objects-smo/tasks/scripting). Or, check out [sp_helptext](https://learn.microsoft.com/en-us/sql/relational-databases/system-stored-procedures/sp-helptext-transact-sql). – R. Richards Apr 24 '17 at 11:05
  • what is the scenerio like ? – KumarHarsh Apr 24 '17 at 11:12
  • The suggestion by R. Richards, using "sp_helptext" was what I was looking for. I wasn't aware of this procedure, thanks :) – Aidal Apr 26 '17 at 07:36

0 Answers0