Getting the script of sql server table and stored procedure with out using SQLSMO COM dll from C#

Hi All,
            I am looking for way by which i can get the script of an sql server table and stored procedure from C# code with out using SQLDMO.dll which is a COM object.Please help.

Jisha.
jisha123Asked:
Who is Participating?
 
Ashutosh VyasFounder, InitQubeCommented:
You can create that manually by obtaining all the columns details of one particular table. You can use something like the below mentioned query to fetch the information of all the columns for a particular table.

select * from syscolumns where id = (select id from sysobjects where name='your_Table_Name' and xtype = 'U')

This will output all the columns for that table and you could manually create a string "Create Table................" which will work as a script for you.

Hope this helps.
0
 
Ashutosh VyasFounder, InitQubeCommented:
You can create a Stored Procedure that will create scripts for you and call that procedure with the name of the SP.

Here is a sample of the same

http://www.eggheadcafe.com/articles/20030609.asp
0
 
jisha123Author Commented:
Hi,
     Thanks.In this way we get the scripts of Stored Procedure using exec sp_helptext @procedurename, but how can i get the script of a table from code.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.