.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

How to get SSMS SCRIPT AS ... output programmatically using VB.NET?

Posted By:      Posted Date: September 08, 2010    Points: 0   Category :Sql Server
I'm looking for a way to get the output from a "SCRIPT AS ... CREATE TO ... New Query Window" under SSMS, but using VB.NET (or C#) code to initiate the output which I can then save off or use internally in my .NET application.Basic idea is that:1.  Connect to a master server2.  Initiate SCRIPT AS ... CREATE TO ... on an existing table3.  Use the scripted TSQL in my application to create that table on another SQL instance/serverExample of scripted output that I want to use in my .NET application   USE [MyTable] GO /****** Object: Table [dbo].[MyTable] Script Date: 03/09/2010 08:24:52 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE TABLE [dbo].[MyTable]( [MyField1] [bigint] IDENTITY(1,1) NOT NULL, [MyField2] [nvarchar](5) NOT NULL, [MyField3] [bigint] NOT NULL, ... I've looked at sp_helptext, but I don't think that is what I need, not sure.Thanks, Rob.

View Complete Post

More Related Resource Links

Script Component - Change One Row Input to Multiple Row Output

Hi All I am new to SSIS, and looking for help. I do not know if it is possible, but I like to try using the "Script Component" to change a input like this:   1234 1235 1236 ...   to and output like this:   1234, Value1 1235, Value2 1235, Value3 1235, Value4 1236, Value5 ...   Depending of the input value, 1 or more Rows are pushed out the Output, Like the value 1234 -> result in 1 Row in the output, where the value 1235 -> result in 3 rows in the output. Is this possible to do in a Script Component?? If it is how do you program such behavior? Do some good sources to learn SSIS exist out there?? I think it is not easy to find information. Peter Schwennesen

How can I avoid entering Output columns manually (with their data types) in the Script Transformatio

I created a wrapper to a WCF web service that is returning many datasets with hundreds of columns.  The destination database schema matches the source schema exactly.  When i make the connection on a ADO.NET destination object to my database it auto-generates my list of columns.  I understand that the script component could output anything so it can't autogenerate at this point, but is there any way to copy and paste the Column definitions from somwhere else and paste them in?  I'd like to avoid spending hours entering all these manually.

How to see 2 script windows in SSMS at once


Hi everybody,

I have multiple monitors (2). I want to be able to work on one SQL Procedure script and check function's code in another window. Presently I had to switch between tabs and this is very inconvenient as I have ~80 different scripts opened and I'm getting lost in them. Is there a way to split the windows to be able to see two particular ones I'm interested in at once?

Thanks in advance.


Premature optimization is the root of all evil in programming. (c) by Donald Knuth

Naomi Nosonovsky, Sr. Programmer-Analyst

My blog

SSMS Table designer does not script index filters



In SQL Server Mgt Studio (SSMS 10.50.1600.1, SQL 10.50.1600), under the table designer, when a table has a filtered index on it, if the modification does need to rebuild the table, the filter is missing on the index.

To reproduce the bug:

-          Create a table

Can not create table via SSMS 2005 GUI even with dbowner rights (I can via ddl script)


I have SQL server 2005 client with SP3 (Microsoft SQL Server Management Studio      9.00.4035.00).

Back end database is SQL server 2008 SP2

I can create/alter a table via sql script.
In the SSMS Database Designer (GUI), When I right click on the database >> Tables and select New Table I get the following error - "Unspecified Error. MS Visual Database Tools."

I was able to use SSMS 2008 client to create tables with out any issues. Looks like a compatibility issue between SSMS 2005 and SS 2008 server.  Has anyone seen this issue and if yes is there a fix for it ?




Need help for configuring COM+ Service programmatically using C# or script

Hi All,

Is it possible to programmaticaly configure  COM+ service.
I need to do the following using C# or any script
1. Open Administrative Tools -> Component Services
2. Expand Components Services -> My Computer -> COM+ Applications
3. Right Click HyperV Environment Manager(COM+ service name) andselect Properties.
4. Click on Pooling & Recycling tab
5. Under Application recycling, set Memory Limit(KB) value to 262144.
6. Click OK
7. Right Click HyperV Environment Manager(COM+ service name)  and select ShutDown
8. Right Click HyperV Environment Manager(COM+ service name)  and select Start
It will be great if you could guide me or send me the code snippet.
Thanks in advance.

Export SharePoint List to Excel Spreadsheet Programmatically using C#

In SharePoint applications, Custom Lists are used to store business data and Document Libraries to store the documents. But for data manupulation and analysis, Microsoft Excel provides very rich features as compared to SharePoint Lists. That's why people still loves to work on Microsoft Excel Sheets.

Creating an Excel Spreadsheet programmatically using VB.NET

The Interoperability services make it very easy to work with COM Capable Applications such as Word and Excel. This article reveals using Excel from a managed application. Excel is the spreadsheet component of Microsoft Office 2000. The majority of Excel programmatic functionality is exposed through Automation via the type library Excel9.olb. The intention of this article is to express that a managed application can interrelate with Excel as a COM server.

Creating an Excel Spreadsheet and Adding Data to It Programmatically

The Interoperability services make it veryeasy to work with COM Capable Applications such as Word and Excel. Thisarticle reveals using Excel from a managed application. Excel is thespreadsheet component of Microsoft Office 2000. The majority of Excelprogrammatic functionality is exposed through Automation via the typelibrary Excel9.olb. The intention of this article is to express that amanaged application can interrelate with Excel as a COM server.

Rendering ASP.NET Script References into the Html Header

One thing that I've come to appreciate in control development in ASP.NET that use JavaScript is the ability to have more control over script and script include placement than ASP.NET provides natively. Specifically in ASP.NET you can use either the ClientScriptManager or ScriptManager to embed scripts and script references into pages via code.

How to programmatically add controls to Windows forms at run time by using Visual C#

Create a Windows Forms Application
Start Visual Studio .NET or Visual Studio 2005 or a later version, and create a new Visual C# Windows Application project named WinControls. Form1 is added to the project by default.
Double-click Form1 to create and view the Form1_Load event procedure.
Add private instance variables to the Form1 class to work with common Windows controls. The Form1 class starts as follows:

Comma-Delimited Output

One of the common tasks performed when retrieving data from a SQL Server database is returning the result as a comma-delimited output instead of a result set. This task can be performed by using a CURSOR selecting the column to be concatenated together. Each row returned by the CURSOR is then concatenated together into a variable separating each one by a comma.

Enterprize library 4.1 getting output parameter after adding record in db, plz guide



I need to get output parameter (flag) from db after saving record in database. I am using Microsoft Enterprise Library 4.1 for DB. I am inserting record using I Data reader.

Please guide


*.axd script references not being rendered to browser


I'm running VS2010 with .net 4.0, and am running into issues with the .net ajax script tags mysteriously not being rendered to the browser.

So far I've reduced it to a scenario where I set the DataSourceID property of a databound control.  More specifically, I've only tested it on a Gridview and a DropDownList.

This can be reproduced fairly easily on my machine by following these steps:

1. Create a new empty Web Application Project

2. Create a new Web Form

3. Add a ScriptManager inside the form

4. Add a DropDownList and a DataSource (I used an ObjectDataSource)

5. Set the DataSourceID property of the DropDownList to the ID of the DataSource.  This can be done either declaratively on the .aspx page, or in the code behind in the aspx.cs page, and both produce the same results.

6. Open the page in a browser and watch as you get a javascript error stating "Sys is not defined" and notice that the page source contains no script tags referencing *.axd scripts.

Here's my source code showing my set up:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="ScriptResourceFAIL.Default" %>


Client script not running


Dear all,

in my MVC 2 application, and in the shared Master Page I wrote this little script for menu handling :

<script src="../../Scripts/jquery-1.4.1.js" type="text/javascript"></script>
<script type="text/javascript"> $(document).ready(function () {   
     $('#nav li').hover(  
         function () {  
             //show its submenu  
             $('ul', this).slideDown(100);  
        function () {  
           //hide its submenu  
            $('ul', this).slideUp(100);           

The script, that shows menu items when the

Potentially dangerous script....blah blah


explain this one - -   (please)

2 projects - same code - one, using 2008, one using 2010 - a textbox a button and a label, using html code in the textbox

In the Page Directive:
EnableEventValidation="false" ValidateRequest="false&q

Inline conditional output


Is it possible to somehow output some content based upon some conditional check in Razor? If not, I hope this possibility will be added in the future. What I want to do is the following:

<option value="1" @if(ListMode == 1) { = "selected=\"true\"" }>Full list</option>

As I can't figure out a way to do this, I have to either make a helper that does it for me or write duplicate code.

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend