Sql Server Script File(.sql) Execution By Vb.net Code

May 20, 2005

I have a problem.

I m working on "light weight sql server"  project.

 

and i want to execute .sql file through vb.net code with the help of sqldmo library and sqlns namespace.

but i donot know any method to directly execute the .sql file.

i am successfully making the full script of select database of sql server.

 

please help me....

thanks....

View 1 Replies


ADVERTISEMENT

SSIS Package Execution From C# Code

Apr 17, 2007



Hi All,



This not a problem but here i wan to give u my some trial on package execution from C# code.

i just want to make sure whether this is right way or not?



I need to upload some processed text file into table using SSIS packages. I m calling these packages in runtime for different source text files passed to it.



I first created package on my machine and deployed packages on Sql server using default protection level. So when i m tryng to execute it from integration services it wont work giving some exception in AquireConnectionCall() , its coz all the sensitive information is stroed inside package is not available to that machine.



In C#

Now i m loading this package using LoadFromSqlServer().
I am creating connection manager object for each of source and destination type and then setting all sensitve information from my solution's config file.
Set the protection level of package and available connection managers to DontSaveSensitve.

by using this method m able to execute any package created on any machine with default protection level.



Can any one of tell me -ve aspects of this approach?



Thanks

View 5 Replies View Related

Simultaneous Execution Of The Same SSIS Package From Code

Jul 26, 2007

Hello

I am trying to call the same package with different starting parameters using asynchronous method calls.

My code is


namespace ReconHost

{






public partial class HostContainer : Form

{



public delegate void InvokePackageHandler(

Microsoft.SqlServer.Dts.Runtime.Application app,
int var
);


Microsoft.SqlServer.Dts.Runtime.Application app;


public HostContainer()

{


InitializeComponent();





for (int i = 0; i < 2; i++)

{


app = new Microsoft.SqlServer.Dts.Runtime.Application();

InvokePackageHandler asyncInvokePackageHandler = InvokePackage;

asyncInvokePackageHandler.BeginInvoke(app, i, null, null);

}


}



public void InvokePackage(Microsoft.SqlServer.Dts.Runtime.Application app, int var)

{


Package pkg = app.LoadPackage(@"c:GRSGRSGRSTest_Async.dtsx", null);

pkg.Variables["intVar"].Value = var;

pkg.Execute();

pkg = null;

}

}





}

If I set the for loop to loop just once, the package is executed fine. Any more than once and only one instance of the package is executed.

Does anyone know what I am doing wrong? I know it is possible to execute the two package instances simultaneously because you can use DTexecUI.exe on two clients to do this.

Thanks in advance
Tomo

View 3 Replies View Related

How Do You Code The Package Execution Progress Window In C#

Mar 25, 2008



I need to write a front end to execute our .dtsx package due to it being encrypted and not wanting to expose the password at all.
I have successfully written code to run it but I want to show something like the Package Execution Progess window and I don't know how.
This window shows up when you just double click on the .dtsx file and Execute it using the interface provided.
Can anyone help?

Here's my code so far.


using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Text;

using System.Windows.Forms;

using Microsoft.SqlServer.Dts.Runtime;



namespace RunMigration

{

public partial class Form1 : Form

{

public Form1()

{

InitializeComponent();

}

private void button1_Click(object sender, EventArgs e)

{



DTSExecResult pkgResults_Sql;



try

{

Cursor.Current = Cursors.WaitCursor;





Microsoft.SqlServer.Dts.Runtime.Application app = new Microsoft.SqlServer.Dts.Runtime.Application();

app.PackagePassword = "SomePassword";



Microsoft.SqlServer.Dts.Runtime.Package pkg = new Microsoft.SqlServer.Dts.Runtime.Package();



pkg = app.LoadPackage("T:\amber\encrypt\EncryptedPHDMigration.dtsx", null);

string mypath = this.textBox1.Text.ToString();

pkg.ImportConfigurationFile(mypath);







pkgResults_Sql = pkg.Execute();

MessageBox.Show(pkgResults_Sql.ToString());

MessageBox.Show(pkg.ExecutionStatus.ToString());







foreach (Microsoft.SqlServer.Dts.Runtime.DtsError error in pkg.Errors)

{

Console.WriteLine("{0}", error.Description);

this.richOutput.Text = error.Description;

}

}

catch (System.Exception f)

{

MessageBox.Show(f.Message);

}

finally

{

Cursor.Current = Cursors.Default;

}

}

private void btnConnect_Click(object sender, EventArgs e)

{

OpenFileDialog open = new OpenFileDialog();

open.Filter = ("SSID config files|*.dtsConfig");

if (open.ShowDialog() == DialogResult.OK)

{

this.textBox1.Text = open.FileName.ToString();

}

}



}

}

View 10 Replies View Related

How To Stop A SSIS Package Execution From Code?

Sep 13, 2006

Hi everyone,

After a Execute method I would need to stop a package but I don't know why:



sResultDts = pkg.Execute(Nothing, Nothing, EventsSSIS, Nothing, Nothing)



I have a Events class (EventSSIS) which implements IDTSEvents and have an OnQueryCancel event but without parameters, such so:

Function OnQueryCancel() As Boolean Implements IDTSEvents.OnQueryCancel

Return False

End Function



Let me know how to pass a boolean parameter because of I can't overloaded OnQueryCancel method

TIA-

View 1 Replies View Related

DTS Package - Provider Generated Code Execution Exception: EXCEPTION_ACCESS_VIOLATI

Feb 23, 2006

When running a step within my DTS package I'm receiving the following error - "Provider generated code execution exception: "EXCEPTION_ACCESS_VIOLATION".

I think it may be something to do with my global variable, but I'm not sure as I'm pretty certain I've set it all up correctly.

Below are screenprints showing my settings.

http://img153.imageshack.us/my.php?image=19tv1.jpg

http://img153.imageshack.us/my.php?image=25wz1.jpg

http://img153.imageshack.us/my.php?image=39pf.jpg

http://img164.imageshack.us/my.php?image=43nx.jpg

http://img164.imageshack.us/my.php?image=51ao.jpg

http://img164.imageshack.us/my.php?image=64lo.jpg

http://img164.imageshack.us/my.php?image=71yn.jpg

Any advice of fixing this would be greatly appreciated.

View 6 Replies View Related

Import A Text File Into A SQL Server Express (C# Code)

Sep 7, 2007

I'm trying to read a text  and load the data from the text file and import the data into the database.please help!! 

View 2 Replies View Related

SQL Server 2008 :: Code To Generate XML File Based In XSD

Aug 2, 2015

I have data in Sql table , I want to convert it to xml using xsd using script component in ssis.

View 0 Replies View Related

Code To Find The Latest File In A Folder And Export It To A Sql Server Table

Feb 15, 2008

Hi Experts,

I have to find the latest file in a folder and export data to a table in sql server.
The code should be something that has to be incorporated into a t-sql stored procedure.

The file name would for example abc_defYYYYMMDD.xls.
would i be able to find the latest file in the folder using the the datestamp (YYYYMMDD) in the filename.

Please note i would have files in other format and names with datestamp attached to it, so the code has to pick specific file for which the file name starts with 'abc_def'

and export data to a table.

Any help would be highly appreciated

View 10 Replies View Related

Reporting Services :: Parsing SSRS Config File And Dynamically Changing File Path Of Config File In Code

Sep 2, 2015

Currently have a single hard coded file path to the SSRS config file which parses the file and provides the reporting services web service url.  My question is how would i run this same query against 100s of servers that may or may not share the same file path as the one hard coded ?

Is there a way to query the registry to find the location of the config file of any server ? which could be on D, E, F, H, etc. 

I know I can string together the address followed by "reports" and named instance if needed, but some instances may not have used the default virtual directory name (Reports).

Am I going about this the hard way ? Is there a location where the web service url exists in a table ? I could not locate anything in the Reporting service database. Basically need to inventory all of my reporting services url's.

View 2 Replies View Related

Help With Converting Code: VB Code In SQL Server 2000-&&>Visual Studio BI 2005

Jul 27, 2006

Hi all--I'm trying to convert a function which I inherited from a SQL Server 2000 DTS package to something usable in an SSIS package in SQL Server 2005. Given the original code here:
Function Main()
on error resume next
dim cn, i, rs, sSQL
Set cn = CreateObject("ADODB.Connection")
cn.Open "Provider=sqloledb;Server=<server_name>;Database=<db_name>;User ID=<sysadmin_user>;Password=<password>"
set rs = CreateObject("ADODB.Recordset")
set rs = DTSGlobalVariables("SQLstring").value

for i = 1 to rs.RecordCount
sSQL = rs.Fields(0).value
cn.Execute sSQL, , 128 'adExecuteNoRecords option for faster execution
rs.MoveNext
Next

Main = DTSTaskExecResult_Success

End Function

This code was originally programmed in the SQL Server ActiveX Task type in a DTS package designed to take an open-ended number of SQL statements generated by another task as input, then execute each SQL statement sequentially. Upon this code's success, move on to the next step. (Of course, there was no additional documentation with this code. :-)

Based on other postings, I attempted to push this code into a Visual Studio BI 2005 Script Task with the following change:

public Sub Main()

...

Dts.TaskResult = Dts.Results.Success

End Class

I get the following error when I attempt to compile this:

Error 30209: Option Strict On requires all variable declarations to have an 'As' clause.

I am new to Visual Basic, so I'm on a learning curve here. From what I know of this script:
- The variables here violate the new Option Strict On requirement in VS 2005 to declare what type of object your variable is supposed to use.

- I need to explicitly declare each object, unless I turn off the Option Strict On (which didn't seem recommended, based on what I read).

Given this statement:

dim cn, i, rs, sSQL

I'm looking at "i" as type Integer; rs and sSQL are open-ended arrays, but can't quite figure out how to read the code here:

Set cn = CreateObject("ADODB.Connection")

cn.Open "Provider=sqloledb;Server=<server_name>;Database=<db_name>;User ID=<sysadmin_user>;Password=<password>"

set rs = CreateObject("ADODB.Recordset")

This code seems to create an instance of a COM component, then pass provider information and create the recordset being passed in by the previous task, but am not sure whether this syntax is correct for VS 2005 or what data type declaration to make here. Any ideas/help on how to rewrite this code would be greatly appreciated!

View 7 Replies View Related

Renaming The File After DTS Package Execution

Nov 1, 2000

Hi,
After executing a dts package to load data from a file to a SQL table. I need to rename the file after the load.
Could any one give me a code sample so that I can add that as a task after the execution of the load in the same package

Ramam

View 3 Replies View Related

Package Execution Details To Log File

May 9, 2008

When you run a deployed package manually, there is a nice load of information output showing you what is going on, this would be very good log file info. Is there anyway to write the same output to a log file when the package is run as a Job from SQL Agent?

View 4 Replies View Related

An Error Occurred During The Execution Of The SQL File 'InstallRoles.sql'.

Mar 27, 2006

    Error text:An error occurred during the execution of the SQL file 'InstallRoles.sql'. The SQL error number is 446 and the SqlException message is: Cannot resolve collation conflict for equal to operation.Cannot resolve collation conflict for equal to operation.Error occurred when running 'aspnet_regsql -S servername -E -d database -A r'with previously installed mambership scheme on database.When googling on this issue, one post on forums.asp.net is listed but link is dead...please help...



   

View 1 Replies View Related

How To Capute Execution Reasults To A Text File

May 16, 2006

How can I save all the text in the SSIS "Execution results" pane to a file? (I can copy 1 line at a time, by right-clicking the message of interest, but there must be a better way.)



TIA,



Barker

View 1 Replies View Related

Set SqlDataSource In Code Behind File

Jan 11, 2006

Hello!
I would like to set the SqlDataSource in the code behind file and not to have it in the aspx file. How can I do that?
Regards,
Gato Gris

View 1 Replies View Related

Unzip File Using C# Code And Asp.net

Mar 7, 2006

hello

my problem is how to unzip the file using the c# and asp.net

code

View 5 Replies View Related

Query A Table For A Value In The Code File.

Feb 7, 2008

Ok, so im pretty much finished writing my forum web page.  However to display things like how many replies each thread has and who replied last, i need to perform a query in the code file.  Im guessing its simple enough but i cant get the syntax for actually performing any query.  I already know the sql syntax like select * from all that stuff but how do i get do something like:
Dim x as integer = sqlQuery("Select count(*) FROM ...")
 Currently i have it all working by creating a table and making it invisible and just pulling data from the table but thats sloppy and pretty ineffecient if i databind a table for every single topic name.

View 9 Replies View Related

Running A Sql Script File Through .net Code

Feb 20, 2008

can anyone tell me how to run the sql server script file saved on my disk through .net code and get the changes done in the database?
 

View 2 Replies View Related

Text File / SqlBulkCopy Code

Apr 29, 2006

Does anybody have the code to import a text file into a a Sql Server table using the SqlBulkCopy object?

View 1 Replies View Related

Exporting Records To A File Through Code

Aug 13, 2007

Hi.

I am writing a program where I import data into a database with a System.Web.UI.WebControls.SqlDataSource object, using its Insert method.



Like this...
Dim DataBaseConnectionString As New Web.UI.WebControls.SqlDataSource()
DataBaseConnectionString.ConnectionString = "Data Source=.SQLEXPRESS;AttachDbFilename=|DataDirectory|Database.mdf;Integrated Security=True;User Instance=True"
DataBaseConnectionString.InsertCommandType = Web.UI.WebControls.SqlDataSourceCommandType.Text
DataBaseConnectionString.InsertCommand = "BULK INSERT TBLMain FROM '/file.csv' WITH (FIRSTROW = 2, FIELDTERMINATOR = ',', ROWTERMINATOR = '')"
DataBaseConnectionString.InsertParameters.Add("csvdatapath", OFDCSV.FileName.ToString())
Try
DataBaseConnectionString.Insert()
Catch ex As Exception



I have been able to get this working fine.

I need to export to (ideally) a .CSV or a .XLS. I have tried to use the:




Code Snippet (SQL)COPY TO '
esults.csv' CSV


Is it possible to use a simmilar method of interacting with the database through code to perform this?

Thanks

View 6 Replies View Related

Sending Parameter To Sqldatasource In Code Behind File

Aug 15, 2007

hi, i have a .aspx.cs code page file and i wanna to send some parameters to sqldatasource in page_load event.i wrote this line of code but it errors that the System.Web.UI.Webcontrols.parameters is a type and not a namespace.here my code:</p><p>&nbsp;</p><pre class="alt2" dir="ltr" style="border: 1px inset ; margin: 0px; padding: 6px; overflow: auto; width: 640px; height: 226px; text-align: left;">if (Session["membartype"].tostring() == "siteadmin1") SqlDataSource1.SelectCommand ="SELECT DocumentID, DocumentCode, DocumentDate,RequestCode, Delivery, Expr1,CityCode, Title FROM (SELECT dbo.EnterDocument.DocumentID, dbo.EnterDocument.DocumentCode, dbo.EnterDocument.DocumentDate,dbo.EnterDocument.RequestCode, dbo.EnterDocument.Delivery, dbo.EnterDocument.EnterType AS Expr1,dbo.EnterDocument.codecity AS CityCode, dbo.Location.Title FrOM dbo.Location RIGHT OUTER JOIN dbo.EnterDocument ON dbo.Location.codecity = dbo.EnterDocument.codecity) AS T1";ParameterCollection parameter=new ParameterCollection[7]; parameter.Add(DocumentID,text,TextBox1.Text); parameter.Add(DocumentCode,text,TextBox4); parameter.Add(FromDocumentDate,text,TextBox6); parameter.Add(untilDocumentDate,text,TextBox5); parameter.Add(PersonID,SelectedValue,DropDownList2); parameter.Add(EnterTypeID,SelectedValue,DropDownList3); parameter.Add(usercode,String,usercode); SqlDataSource1.SelectParameters.Add(parameter); GridView1.DataBind();</pre><p>  thanks,M.H.H 

View 2 Replies View Related

Execute Stored Procedure From Code Behind File

Mar 15, 2008

hi all
I have to execute the stored procedure from code file
string constr = ConfigurationSettings.AppSettings["ConnectionString"];SqlConnection con = new SqlConnection(constr);con.Open();SqlCommand cmd = new SqlCommand("GetTax",con);cmd.CommandType = CommandType.StoredProcedure;SqlParameter paramFrom = new SqlParameter("@from", SqlDbType.VarChar, 50);paramFrom.Value = "JFK";SqlParameter paramTo = new SqlParameter("@To", SqlDbType.VarChar,50);paramTo.Value = "HOU";SqlParameter paramAirline = new SqlParameter("@Airline", SqlDbType.VarChar,50);paramAirline.Value = "US";SqlParameter rpTax = new SqlParameter("@Tax",SqlDbType.Int);rpTax.Direction = ParameterDirection.Output;cmd.Parameters.Add(rpTax);
insted of this way can i execute stored procedure any other way
like
exec MystoredProc "param1"."param2","param3"
 i appreciate u r help
 
 
 

View 2 Replies View Related

Any One Tell Me The Code To Connect To .sdf File In C# Windows Application?

Apr 10, 2008

Hi,

Any one tell me the code to connect to .sdf file in c# windows application?And tell the requirments to conncet.My sdf file path is this

C:\Documents and Settings\koti\My Documents\Example.sdf

I write this code.It is not working

string str = "Provider=Microsoft.SQLSERVER.MOBILE.OLEDB.3.0;Data Source=C:\Documents and Settings\koti\My Documents\Example.sdf;SSCE:Encrypt Database=True";
SqlCeConnection cn = new SqlCeConnection(str);
cn.Open();

Ant one help me Plz...

Regards,
venkat.

View 6 Replies View Related

Code Creating A Flat File Destination

Apr 21, 2006

I'm looking for a manner to create by code a flat file connection manager and a flat file destination.Greets

View 3 Replies View Related

Static Variables In A SQLCLR Stored Proc Seem To Get Reused From Execution To Execution Of The Sp

Aug 23, 2007

after moving off VS debugger and into management studio to exercise our SQLCLR sp, we notice that the 2nd execution gets an error suggesting that our static SqlCommand object is getting reused from the 1st execution (of the sp under mgt studio). If this is expected behavior, we have no problem limiting our statics to only completely reusable objects but would first like to know if this is expected? Is the fact that debugger doesnt show this behavior also expected?

View 4 Replies View Related

Using SqlDataSource To Execute A Select Statement In The Code File???

Nov 27, 2006

Hi you all,
In abc.aspx, I use a GridView and a SqlDataSource with a SelectCommand. The GridView's DataSourceID is the SqlDataSource.
In abc.aspx.cs, I would like to use an IF statement in which if a criterion is not satistied then I will use the SqlDataSource with another SelectCommand string. Unfortunately, I have yet to know how to write code lines in order to do that with the SqlDataSource. Plz help me out!

View 1 Replies View Related

Ugrent Help: How To Write Code To Execute A Batch File

Apr 15, 1999

hi, I need to run a batch file in specific time of the week. can anyone show me the code to run a batch file with both ways: window nt schedualer and ms sql server task manger.... I do appreciate your help

Ali

View 5 Replies View Related

Help,a Regular Text File How To Sql 2000 Table Code ?

Apr 5, 2008

help,a regular text file how to sql 2000 table code ?i have a text file as follow, line with ¡°|¡±and {LF},8|-000000186075919.|+000000000387820.|2008-03-31|20010423|9|-000000000003919.|-000000000123620.|2008-03-31|20010123|8|-000000018623419.|+000000000381230.|2008-05-30|20010423|i want to sign char(1)£¬year decimal(18,3) , month decimal(18,3), trandatesmalldatetime£¬update smalldatetime£¬after to sql table is as follow,sign year month trandate update8 -186075919.000 387820.000 3/31/2008 4/23/20019 -3919.000 -123620.000 3/31/2008 1/1/20018 -18623419.000 387820.000 5/30/2008 4/23/2001could you help me how write the sql code ?

View 1 Replies View Related

Integration Services :: C# Code To Create File From Variable Value?

May 5, 2015

My Execute SQL Task will store the file name into a variable(mFile) of type string datatype.

Now I wanted a script task (C# code) to create a filename from the variable (mFile) value.

Since it is a common issue I tried a lot in the internet but none of the queries worked.

View 10 Replies View Related

Retrieving A File Link From The Database And Including Its Code On Page

Dec 21, 2004

Hi there folks,

was just wondering if there was an easy way to include a files contents into a web page via a database field. A bit confusing i know.

Here goes:

I got a field called ContentPage stored in a database. (e.g Index.htm)

I want to retrieve this page and then include its contents in my middle div of the webpage like so: <!--#include file="<%=ContentPage%>"-->. Not allowing me to do this as you may have guessed. These pages will either be htm or aspx pages. This would make my life so much easier.

Is there any way of doing this or am i kidding myself.

Would appreciate any help.

Paul

View 1 Replies View Related

Script Destination Component Code Sample Here That Creates A Csv Or Xml File

Jul 11, 2006

After much work and thanks to all of you who helped on this here is a code sample that can be adapted. From the dataflow task add an OLEDB source component, a row count component and finally a Script Destination Component.

On the Script Destination Component rename the Input node of the imports and outputs tree view to "ParsedInput"

The readonly User: variables that start with gs can be read in the PreExecute method

The readwrite User: variable giSuccessCount can only be used in the post execute task because it is populated by the Row Count Component which is the previous object in the Dataflow

The xml code is adapted from an idea in Donald Farmers book

enjoy

Dave

Now if someone can make a Script Source Component that can read a file with a header , data body and trailer that would b egreat!
' Microsoft SQL Server Integration Services user script component
' This is your new script component in Microsoft Visual Basic .NET
' ScriptMain is the entrypoint class for script components
 
Imports System
Imports System.Data
Imports System.Math
Imports System.IO
Imports Microsoft.SqlServer.Dts.Pipeline.Wrapper
Imports Microsoft.SqlServer.Dts.Runtime.Wrapper
Imports System.Xml
 
Public Class ScriptMain
    Inherits UserComponent
    Dim sw As StreamWriter
    'In addition to using the Imports System.Xml statement a reference must be added to the
    'System.Xml assembly  (Select Project-Add Reference from IDE)
    Dim xWriter As XmlTextWriter
    Dim OutputFileType As String '.csv or .xml
 
 
 
    Public Overrides Sub PreExecute()
       
        'Read Only variables
        Dim gsPickUp As String = Me.Variables.gsPickUp 'D:ftprootOutAvid'
        Dim gsPickUpFilename As String = Me.Variables.gsPickUpFilename '1_AVID_'
        Dim gsPickUpFileExtn As String = Me.Variables.gsPickUpFileExtn '.csv'
        Dim gsMemoText As String = Me.Variables.gsMemoText 'Memo Text : credit adjustment'
        Dim gsStatementText As String = Me.Variables.gsStatementText 'Statment Text : credit adjustment'
        Dim gsRunMode As String = Me.Variables.gsRunMode 'UPDATE'
        Dim fileName As String = gsPickUp & "" & gsPickUpFilename
        fileName = fileName & (Format(Now(), "yyMMdd").ToString)
        'MsgBox(fileName)
 
        OutputFileType = gsPickUpFileExtn
        If OutputFileType = ".csv" Then
            fileName = fileName & gsPickUpFileExtn
            sw = New StreamWriter(fileName) 'connection to dest file
 
            'Header records
            sw.Write(gsRunMode)
            sw.Write(Environment.NewLine) ' end of line
            sw.Write(gsMemoText)
            sw.Write(Environment.NewLine)
            sw.Write(gsStatementText)
            sw.Write(Environment.NewLine)
            sw.Write(Environment.NewLine) 'Spacer
        End If
 
        If OutputFileType = ".xml" Then
            fileName = fileName & gsPickUpFileExtn
            'xWriter = New XmlTextWriter(Me.Connections.XMLConnection.ConnectionString, Nothing)
            'xWriter.WriteStartDocument()
            'xWriter.WriteComment("Customer file parsed using script")
            'xWriter.WriteStartElement("x", "customer", "http://some.org/name")
            'xWriter.WriteAttributeString("FileName", Me.Connections.XMLConnection.ConnectionString)
            xWriter = New XmlTextWriter(fileName, Nothing)
            xWriter.WriteStartDocument()
            xWriter.WriteComment("Customer file parsed using script")
            xWriter.WriteStartElement("x", "customer", "http://some.org/name")
            xWriter.WriteAttributeString("FileName", fileName)
        End If
 
 
    End Sub
 
 
 
    Public Overrides Sub ParsedInput_ProcessInputRow(ByVal Row As ParsedInputBuffer)
 
 
        If OutputFileType = ".csv" Then
            Dim delim As String = ","
 
            sw.Write(Row.ProjectID.ToString + delim)
            sw.Write(Row.TransactionRefNum.ToString + delim)
            sw.Write(Row.CustomerNum.ToString + delim)
            sw.Write(Row.AccountNum.ToString + delim)
                         
            sw.Write(Environment.NewLine) ' end of line
            sw.Flush() 'send the stream to file
        End If
 
 
 
        If OutputFileType = ".xml" Then
            xWriter.WriteStartElement("CUSTOMER")
 
            xWriter.WriteStartElement("ProjectID")
            xWriter.WriteString(Row.ProjectID.ToString)
            xWriter.WriteEndElement()
 
            xWriter.WriteStartElement("TransactionRefNum")
            xWriter.WriteString(Row.TransactionRefNum.ToString)
            xWriter.WriteEndElement()
 
            xWriter.WriteStartElement("CustomerNum")
            xWriter.WriteString(Row.CustomerNum.ToString)
            xWriter.WriteEndElement()
 
            xWriter.WriteStartElement("AccountNum")
            xWriter.WriteString(Row.AccountNum.ToString)
            xWriter.WriteEndElement()
 
             
 
        End If
 
 
 
       
       
    End Sub
 
    Public Overrides Sub PostExecute()
 
       
 
        If OutputFileType = ".csv" Then
            'Create the trailer
            sw.Write(Environment.NewLine) ' blank line
            sw.Write("RECORD_COUNT: " & Me.Variables.giSuccessCount.ToString) 'ReadWrite Varible
            sw.Write(Environment.NewLine)
            sw.Flush() 'send the stream to file
            'Close file
            sw.Close()
        End If
 
        If OutputFileType = ".xml" Then
            xWriter.WriteStartElement("RecordCount")
            xWriter.WriteString(Me.Variables.giSuccessCount.ToString)
            xWriter.WriteEndElement()
            xWriter.WriteEndElement()
 
            xWriter.WriteEndDocument()
            xWriter.Close()
        End If
 
    End Sub
 
 
End Class
 
 
 



 

View 6 Replies View Related

Integration Services :: SSIS Package - Create Different TXT File For Each Code

Jun 25, 2015

CREATE TABLE Test
(
EDate Datetime,
Code varchar(255),
Cdate int,
Price int
);
drop table Test

[Code] ....

I have this Query and the below output:

EDate Code CDate Price
2015-06-24  RX 20150701 22
2015-06-24  RX 20150701 28
2015-06-24  RX 20150701 43

[Code] ....

Now the task is to create  SSIS package which will create different .txt file for each Code

1) RX20150624.txt
2015-06-24 00:00:00.000 RX 20150701 22
2015-06-24 00:00:00.000 RX 20150701 28
2015-06-24 00:00:00.000 RX 20150701 43

2) NG20150623.txt
2015-06-23 00:00:00.000 NG 20150701 43

3) HO20150624.txt
2015-06-24 00:00:00.000 HO 20150701 43
And so on..

But the requirement is to have a dynamic query where we can have more number of Codes or less number of codes and similarly the package should generate dynamic text files, one .txt file per code. What is the best way to create a package which can meet the above requirement?

View 6 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved