Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


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

Posted on 2007-08-01
Medium Priority
Last Modified: 2013-12-03
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.

Question by:jisha123
  • 2

Assisted Solution

by:Ashutosh Vyas
Ashutosh Vyas earned 750 total points
ID: 19614826
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


Author Comment

ID: 19614937
     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.

Accepted Solution

Ashutosh Vyas earned 750 total points
ID: 19615050
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.

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
High user turnover can cause old/redundant user data to consume valuable space. UserResourceCleanup was developed to address this by automatically deleting user folders when the user account is deleted.
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
As many of you are aware about Scanpst.exe utility which is owned by Microsoft itself to repair inaccessible or damaged PST files, but the question is do you really think Scanpst.exe is capable to repair all sorts of PST related corruption issues?

571 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question