Execute Multiple Sql Commands With One Trip To The Database.

Jun 12, 2007

Ive got a List<sqlCommand> and I want to execute all the commands in it, but only using one trip to the database. I dont need any return values from any of these commands. Most of the commands are update/insert/delete. Sometimes after a insert command there may be a command "set @NEWID =identity_insert"  to facilitate the next insert to a related table, but thats the only other type of command to insert/update/delete.
I am using microsofts enterprise data application block. I want to execute all the commands in the list with just one trip to the database. Would the following code achieve this :
 db = DatabaseFactory.CreateDatabase("wlmAdmin");
 foreach (SqlCommand sc in saveCommands)
            {
                db.ExecuteNonQuery(sc);
            }
or would this make multiple trips to the database? Im not 100% on whats going on behind the db object. If I create the db Item in the constructor of my class using "db = DatabaseFactory.CreateDatabase("wlmAdmin");" would this mean that every instance of that class would maintain an open database connection throughout its scope/lifetime?

Ive created the class to retrieve all data using a single stored procedure and then when saving, the class builds a List of SqlCommands which as Ive mentioned I want to execute in one trip, to make the number of trips to the database as small as possible. Because of this I don't need the db object maintain an open connection to the database all the time. However It doesnt seem to have any dispose methods so Im not clear on how it operates.
In the case that the code above opens a connection for each command, how would I got about batch executing the queries in one trip?
Thanks,
C
 
 

 
 

View 12 Replies


ADVERTISEMENT

Execute Sql Commands Through Command Prompt

Nov 15, 2007

Hi,

I wanted to know if there is a way to execute sql commands on the operating system's command line. If it is possible, then how do we do it ? For example to execute a SELECT * from Table statement what are we supposed to do ?

Thanks
S

View 2 Replies View Related

Can Anyone Explain What The Pre-execute Phase Is Doing For OLE DB Data Sources Using Sql Commands?

Nov 3, 2006

I have a project which spans multiple servers and aggregates literally billions of rows of data into a much smaller and manageable result set which I store on another server. There are two stored procedures which take up 99.9% of the processing time. Each one of these SPs are estimated to run over 3 hours a piece (gives you an indication of how much data there really is). With in this SSIS package, I have two control flows, one for each SP. When I run the SSIS package from VS2005, I can see that there is a pre-execute phase which takes about an hour abnd a half to complete, and then move on to executing. My question is, what the heck is this, and what is it doing? I know it validates the sql in the procedure, but does it actually run the SP during that pre-execute phase? If it does, is there any way to get around that?

Any help would be appreciated.

View 8 Replies View Related

Multiple SQL Commands At Once

Jan 8, 2006

I'm running asp.net 2.0 and acessing MSSQL 2K.  I am trying to run a query in which I need to set up variables first.  I tried the following group of commands as shown, passing it to the  SqlDataReader object, but it failed.. does anyone know how i can pass multiple SQL commands?         MainQuery = "declare @MinGrades as Table(GradeID Bigint) " & _                    " INSERT @MinGrades SELECT MIN(CreditGrades.SplitID) AS Expr1" & _                       "  FROM          CreditGrades INNER JOIN" & _                        "    CreditGradeSplits ON CreditGradeSplits.CreditGradeSplitID = CreditGrades.SplitID " & _                        " WHERE      (CreditGrades.x0x30 = - 1 OR " & _                        "    CreditGrades.x0x30 >= 0) AND (CreditGrades.x1x30 = - 1 OR " & _                        "    CreditGrades.x1x30 >= 0) AND (CreditGrades.x2x30 = - 1 OR " & _                        "    CreditGrades.x2x30 >= 0) AND (CreditGrades.x3x30 = - 1 OR " & _                        "    CreditGrades.x3xNOD >= 0) " & _                        " GROUP BY CreditGradeSplits.CreditGradeGroupID" & _                    " Select * from @MinGrades "

View 2 Replies View Related

Integrity With Multiple Commands

Aug 10, 2006

How can I make sure that a couple of commands are either all executed on the database or none of them. For example right now I have an insert, update and delete command. I'm calling each of them with a SqlCommand. So I am afraid that that one of them might be executed, then there's a bad connection and the other two are not. How can I prevent this so that only all commands or nothing is executed on the database?

View 2 Replies View Related

Problems With Multiple Commands Using Views

Jan 10, 2008

I am new to SQL, so I appologize if I am doing something wrong which is really basic.
I am receiving a "Incorrect syntax near ';' " when trying to create a view and then perform action based upon the results
Here is my basic code...the error is on the ; following the create view statement:
create view temp2 as select * from history where crc='XL' and processed<1;
insert into history2 (dialid, calldatetime, origcalldate, crc, revenue, projectid, agentid, phonenum)select  temp2.dialid, temp2.calldatetime, temp2.calldatetime, 'XL', 0, history2.projectid, temp2.agentid, temp2.phonenum from temp2, history2where temp2.dialid=history2.dialid and temp2.crc='XL' and temp2.processed<1 and temp2.projectid=110;
What am I doing wrong???
 Thanks for your help.

View 5 Replies View Related

Multiple Concurrent Sql Exec Commands?

Mar 12, 2008

I was wondering if it was possible to run 2 queries at the same time,IE rather than runningexec query1  exec query2 and having to wait for query1 to finish before query2 started, just have them run at the same time (they're not conflicting).I want to do this in TSQL, not by opening another query window in vs2005. 

View 2 Replies View Related

Running Multiple Commands On Single Button Click

Feb 21, 2008

I have a form that contains data that some of which needs to be inserted into one table and the rest updated to another table. I want this to happen on a single button click. Is this possible?Here's what I have so far:            String id = parm_tb_tktid.Text;            String update = parm_tb_desc.Text;            String status = parm_cb_status.Text;                     SqlCommand cmd = new SqlCommand("Insert into History (tkt_id, hist_desc) values(@parm_tb_tktid, @parm_tb_desc)", HelpdeskConnectionString);            cmd.CommandType = CommandType.Text;            cmd.Parameters.AddWithValue("@parm_tb_tktid", id);            cmd.Parameters.AddWithValue("@parm_tb_desc", update);                        SqlCommand cmd1 = new SqlCommand("Update Ticket (tkt_status) values(@parm_cb_status) where tkt_id = @parm_tb_tktid)", HelpdeskConnectionString);            cmd1.CommandType = CommandType.Text;            cmd1.Parameters.AddWithValue("@parm_cb_status", status);            HelpdeskConnectionString.Open();            cmd.ExecuteNonQuery();            cmd1.ExecuteNonQuery();            HelpdeskConnectionString.Close();            parm_tb_tktid.Text = String.Empty;            parm_tb_desc.Text = String.Empty;            parm_cb_status.Text = String.Empty;I know it isn't right, but I can't find any info on why it's wrong and how to code it properly.  

View 9 Replies View Related

What Is Going On Here? SQL Commands And ODBC Commands Aren't Compatible

Oct 1, 2004

I'm building a simple webform, except Visual Studio and my service provider have combined to drive me nutty.

First, I MUST use an ODBC connection to my remote SQL Server do to some unknown configuartion problem. I've been playing with Visual Studio for only a month, so normally when something goes wrong I can go look in the mirror and find the culprit. This is different. I've got a totally functional web form with a SQL Connection, but when I try to change it to an ODBC Connection, I get the following error.

An OdbcParameter with ParameterName '@CertHolder' is not contained by this OdbcParameterCollection

My coding is fine because I stole it straight from the walkthrough and it works. But the specifications that Visual Studio provide are quite suspect. Please note the failure to include some key "@" signs.


#Region " Web Form Designer Generated Code "

'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.SqlConnection1 = New System.Data.SqlClient.SqlConnection
Me.cmdUpdate = New System.Data.SqlClient.SqlCommand
Me.cmdGetAll = New System.Data.SqlClient.SqlCommand
Me.cmdSelect = New System.Data.SqlClient.SqlCommand
Me.OdbcConnection1 = New System.Data.Odbc.OdbcConnection
Me.OdbcGetAll = New System.Data.Odbc.OdbcCommand
Me.OdbcSelect = New System.Data.Odbc.OdbcCommand
Me.OdbcUpdate = New System.Data.Odbc.OdbcCommand
'
'SqlConnection1
'
Me.SqlConnection1.ConnectionString = "this works fine"
'
'cmdUpdate
'
Me.cmdUpdate.CommandText = "UPDATE InsuranceData SET Name = @Name, Address = @Address, Address2 = @Address2, " & _
"City = @City, State = @State, Zip = @Zip, CertHolder = WHERE (CertHolder = @Cert" & _
"Holder)"
Me.cmdUpdate.Connection = Me.SqlConnection1
Me.cmdUpdate.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Name", System.Data.SqlDbType.NVarChar, 50, "Name"))
Me.cmdUpdate.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Address", System.Data.SqlDbType.NVarChar, 50, "Address"))
Me.cmdUpdate.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Address2", System.Data.SqlDbType.NVarChar, 50, "Address2"))
Me.cmdUpdate.Parameters.Add(New System.Data.SqlClient.SqlParameter("@City", System.Data.SqlDbType.NVarChar, 50, "City"))
Me.cmdUpdate.Parameters.Add(New System.Data.SqlClient.SqlParameter("@State", System.Data.SqlDbType.NVarChar, 50, "State"))
Me.cmdUpdate.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Zip", System.Data.SqlDbType.NVarChar, 50, "Zip"))
Me.cmdUpdate.Parameters.Add(New System.Data.SqlClient.SqlParameter("@CertHolder", System.Data.SqlDbType.NVarChar, 50, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "CertHolder", System.Data.DataRowVersion.Original, Nothing))
'
'cmdGetAll
'
Me.cmdGetAll.CommandText = "SELECT CertHolder, Name, Address, Address2, City, State, Zip FROM InsuranceData"
Me.cmdGetAll.Connection = Me.SqlConnection1
'
'cmdSelect
'
Me.cmdSelect.CommandText = "SELECT CertHolder, Name, Address, Address2, City, State, Zip FROM InsuranceData W" & _
"HERE (CertHolder = @CertHolder)"
Me.cmdSelect.Connection = Me.SqlConnection1
Me.cmdSelect.Parameters.Add(New System.Data.SqlClient.SqlParameter("@CertHolder", System.Data.SqlDbType.NVarChar, 50, "CertHolder"))
'
'OdbcConnection1
'
Me.OdbcConnection1.ConnectionString = "This works fine"
'
'OdbcGetAll
'
Me.OdbcGetAll.CommandText = "SELECT CertHolder, Name, Address, Address2, City, State, Zip FROM InsuranceData"
Me.OdbcGetAll.Connection = Me.OdbcConnection1
'
'OdbcSelect
'
Me.OdbcSelect.CommandText = "SELECT CertHolder, Name, Address, Address2, City, State, Zip FROM InsuranceData W" & _
"HERE CertHolder = @CertHolder"
Me.OdbcSelect.Connection = Me.OdbcConnection1
Me.OdbcSelect.Parameters.Add(New System.Data.Odbc.OdbcParameter("CertHolder", System.Data.Odbc.OdbcType.NVarChar, 50, "CertHolder"))
'
'OdbcUpdate
'
Me.OdbcUpdate.CommandText = "UPDATE InsuranceData SET Name = @Name, Address = @Address, Address2 = @Address2, " & _
"City = @City, State = @State, Zip = @Zip WHERE CertHolder = @CertHolder"
Me.OdbcUpdate.Connection = Me.OdbcConnection1
Me.OdbcUpdate.Parameters.Add(New System.Data.Odbc.OdbcParameter("Name", System.Data.Odbc.OdbcType.NVarChar, 50, "Name"))
Me.OdbcUpdate.Parameters.Add(New System.Data.Odbc.OdbcParameter("Address", System.Data.Odbc.OdbcType.NVarChar, 50, "Address"))
Me.OdbcUpdate.Parameters.Add(New System.Data.Odbc.OdbcParameter("Address2", System.Data.Odbc.OdbcType.NVarChar, 50, "Address2"))
Me.OdbcUpdate.Parameters.Add(New System.Data.Odbc.OdbcParameter("City", System.Data.Odbc.OdbcType.NVarChar, 50, "City"))
Me.OdbcUpdate.Parameters.Add(New System.Data.Odbc.OdbcParameter("State", System.Data.Odbc.OdbcType.NVarChar, 50, "State"))
Me.OdbcUpdate.Parameters.Add(New System.Data.Odbc.OdbcParameter("Zip", System.Data.Odbc.OdbcType.NVarChar, 50, "Zip"))
Me.OdbcUpdate.Parameters.Add(New System.Data.Odbc.OdbcParameter("Original_CertHolder", System.Data.Odbc.OdbcType.NVarChar, 50, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "CertHolder", System.Data.DataRowVersion.Original, Nothing))

I NEVER EVER TYPED ORIGINAL_CERTHOLDER IN THE SQL PREPARATION

End Sub
Protected WithEvents btnSave As System.Web.UI.WebControls.Button
Protected WithEvents SqlConnection1 As System.Data.SqlClient.SqlConnection
Protected WithEvents ddlCertHolder As System.Web.UI.WebControls.DropDownList
Protected WithEvents txtName As System.Web.UI.WebControls.TextBox
Protected WithEvents txtAddress As System.Web.UI.WebControls.TextBox
Protected WithEvents ddlCH As System.Web.UI.WebControls.DropDownList
Protected WithEvents cmdUpdate As System.Data.SqlClient.SqlCommand
Protected WithEvents cmdGetAll As System.Data.SqlClient.SqlCommand
Protected WithEvents cmdSelect As System.Data.SqlClient.SqlCommand
Protected WithEvents txtAddress2 As System.Web.UI.WebControls.TextBox
Protected WithEvents txtCity As System.Web.UI.WebControls.TextBox
Protected WithEvents txtState As System.Web.UI.WebControls.TextBox
Protected WithEvents txtZip As System.Web.UI.WebControls.TextBox
Protected WithEvents OdbcConnection1 As System.Data.Odbc.OdbcConnection
Protected WithEvents OdbcGetAll As System.Data.Odbc.OdbcCommand
Protected WithEvents OdbcSelect As System.Data.Odbc.OdbcCommand
Protected WithEvents OdbcUpdate As System.Data.Odbc.OdbcCommand

'NOTE: The following placeholder declaration is required by the Web Form Designer.
'Do not delete or move it.
Private designerPlaceholderDeclaration As System.Object

Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub

#End Region


Comments? Suggestions, I am not positive about how to fix this.

View 2 Replies View Related

Did I Just Trip Over A Golden Egg?

Dec 16, 2005

I'v been scouring the MSDN library and asking in newsgroups, forums, etc. on a way to extract [only] the time from a DateTime field (for a stored procedure) and no one could answer my question. then I tried this in QA:
select right(getdate(),7)
and I found an answer.  I'm now looking for someone to prove this is either a golden egg, a goose egg, or a documented feature I missed and if so where, so I can learn from it.
Jon

View 5 Replies View Related

Executing N Procedures In 1 Round Trip

Apr 30, 2006

w/ SqlServer, is there anyway to pack a number of calls to the same stored procedure into a single round-trip to the DB short of dynamically writing a T-SQL block?  For example, if I'm calling a procedure "Update Contact" which takes 2 params @Campaign, @Contact 20 times how would I pass in the values for those 20 diffrent versions?

View 6 Replies View Related

Retrieving Database DDl Commands

Mar 25, 2008

 Hi everyoneI created a database graphically in VS2005.Now I want the text version of those DDL(create) commands. Question is where and how are those commands stored in SqlServer  I have the management studio too. Any ideas?? 

View 2 Replies View Related

Running Returned Results Through A Stored Procedure All In One Trip

Nov 6, 2006

Hi,
I need to write a select query that will run all returned results through a separate stored procedure before returning them to me.
Something like....
SELECT TOP 10 userid,url,first name FROM USERS ORDER by NEWID()
......and run all the selected userids through a stored procedure like.....
CREATE PROCEDURE AddUserToLog (@UserID int ) AS INSERT INTO SelectedUsers (UserID,SelectedOn) VALUES (@UserID,getdate())
 Can anyone help me to get these working togethsr in the same qurey?
 
Thanks

View 7 Replies View Related

Can We Insert/Update Into Related Tables In A Single Round Trip ?

Sep 25, 2002

I would like to update/insert data into a Orderhearder Table along with the related details into the corrosponding OrderDetails Tables. Can this be done using a single stored procedure or do we have to make one call to the UpdateOrderHeader Stored Procedure and loop thru all the details and call the UpdateOrderDetails Stored Procedure. How do we handle the Transactions in such a case ?

Thanks

Anurag Agarwal

View 1 Replies View Related

Is There A Way Using Sqlexpress To Review The Most Recent Set Of Sql Commands Submitted To A Database?

May 18, 2007

is there a way using sqlexpress to review the most recent set of sql commandssubmitted to a database?I remember something about setting up logging in sql server 2000, but don'tsee much about this on google or the news group for 2005.thanksJeff Kish

View 2 Replies View Related

How To Execute Multiple Statements?

Sep 17, 2007

Is there a way to execute multiple SQL statements within SQL Server? I'm triyng to write a sql statement that will delete from three tables. I need at least two sql statements to delete from these three tables. Can this be done?

View 12 Replies View Related

Cannot Execute Job With Multiple Packages

Mar 28, 2008

I have a schedule job that errors out on the first step when I attempt to run it. There are 3 packages that I created and I can run them all manually just fine.

I get this error when I try to run the job:
-----------------------------------------------


Date,Source,Severity,Step ID,Server,Job Name,Step Name,Notifications,Message,Duration,Sql Severity,
Sql Message ID,Operator Emailed,Operator Net sent,Operator Paged,Retries Attempted

03/28/2008 13:49:22,ST Customer Data,Error,0,Server01,ST Customer Data,(Job outcome),,The job failed.

The Job was invoked by User sa.

The last step to run was step 1 (config 1).

The job was requested to start at step 1 (config 1).,00:00:01,0,0,,,,0


03/28/2008 13:49:22,ST Customer Data,Error,1,Server01,ST Customer Data,config 1,,

Executed as user: Server01SYSTEM. ...9.00.3042.00 for 32-bit

Copyright (C) Microsoft Corp 1984-2005. All rights reserved.

Started: 1:49:23 PM Error: 2008-03-28 13:49:23.23
Code: 0xC0016016 Source:

Description: Failed to decrypt protected XML node "DTS:Password" with

error 0x8009000B "Key not valid for use in specified state.".

You may not be authorized to access this information.

This error occurs when there is a cryptographic error.
Verify that the correct key is available. End Error

Error: 2008-03-28 13:49:23.57 Code: 0xC0202009
Source: Config 1 Customer Data Connection manager "SourceConnectionOLEDB"
Description: SSIS Error Code DTS_E_OLEDBERROR.

An OLE DB error has occurred. Error code: 0x80040E4D.
An OLE DB record is available.
Source: "Microsoft SQL Native Client" Hresult: 0x80040E4D
Description: "Communication link failure".

An OLE DB record is available.
Source: "Microsoft SQL Native Client"
Hresult: 0x80...
The package execution fa...
The step failed.,00:00:01,0,0,,,,0

-----------------------------------------------


Any ideas?

Thanks,

John

View 2 Replies View Related

Execute Multiple Statements At Once...

Oct 17, 2006

I am not even sure if this is possible but I want to be able to excute several statements (or SPs) at once from inside a SPs (or any other method).

What I am doing is a I am taking data from a single column, multiple rows and making it into one row (i.e. data1 + data2 + data3....) But I am doing this to a total of 2.1 million individual rows and the result will be about 204k rows.... what I have written is basically a nested loop and it works fine but very slow... slow as in it has been running for 24 hours now and it is about 60% done... I need this to finish in under 36 hours preferably...

If I could handle more than one set of data at once (there will be no duplicates) I could speed up the process by how ever many I feel like working with...

So is there a way to execute a statement (sp or function) and go to the next statement without waiting for the first to finish??



Thanks Big Time... I hope this is possible.

OH.... SQL 2000 SP4 on Windows 2003.

View 16 Replies View Related

Execute Sql On Multiple Objects (DB's Or Tables)

Jul 12, 2006

Hi,
Because I'me a newbie on this... and I don't want to make a monstrous-query, please some advice on this:

In pseudo-code:

for objectname in (specified list of objects)
do
some sql code (i.e. create table xyz)
done

With 'objects' I mean a database or table name.

I've searched and found the foreachdb option, but I don't want to execute the sql n ALL db's but only the ones specified.

Any help is appreciated!

View 1 Replies View Related

How To Execute Insert Statement To Multiple DB's

Apr 21, 2008

I have the following insert how can i execute to multiple databases on same server:

insert into Tablerecords(labelkey,moduletype,english,spanish,updatedby)
values('hypUnderConstruction','MENU','Under Construction','Under Construction','admin')

databases: db1,db2,db3,db4,db5 etc

Thanks.

View 5 Replies View Related

How To Execute Multiple Queries In Ssis?

Jan 26, 2007

Hi there,

I am new to ssis.I need to execute multiple queries to update number of tables in sqlserver.Pleasesuggest me the right way to do this.



Thanks in Advance.

Regards

Vinod

View 4 Replies View Related

How To Execute Multiple Reports With The Same Parameter

Mar 29, 2007

We have timed-based subscriptions set up for our standard set of 10 client
reports which run monthly with the appropriate parameters set for each
of our clients. Our management has requested that we provide them with
the ability to run the set of 10 reports together at will. So we would
provide the client parameter and all 10 reports would be generated.
What is the recommended approach to accomplish this? We are using Sql
Server 2005, Visual Studio 2003 and .Net 2.0.

View 1 Replies View Related

Execute Multiple SQL Statements In Stored Proc

Nov 1, 2005

Hi, I have a table containing SQl statements. I need to extract the statements and execute them through stored procedure(have any better ideas?)

Table Test

Id Description

1Insert into test(Id,Name) Values (1,'Ron')
2Update Test Set Name = 'Robert' where Id = 1
3Delete from Test where Id = 1


In my stored procedure, i want to execute the above statements in the order they were inserted into the table. Can Someone shed some light on how to execute multiple sql statements in a stored procedure. Thanks

Reo

View 2 Replies View Related

How To Execute A Stored Procedure With Multiple Parameters In VB

Aug 3, 2012

Here is my stored procedure:

ALTER PROCEDURE dbo.SP_UpdateFixedRev
/*
(
@parameter1 int = 5,
@parameter2 datatype OUTPUT
)
*/
(
@Number int,
@FixedRev money
)
AS
BEGIN
/* SET NOCOUNT ON */
Update Ticket set FixedRev = @FixedRev where Number = @Number;
End

Here is my code:

Dim dbConn As New OleDbConnection
Dim dbComm As OleDbCommand
dbConn.ConnectionString = connStr 'connStr is class-level vrbl
dbConn.Open()
dbComm = dbConn.CreateCommand
dbComm.Parameters.Add("@Number", OleDbType.Integer).Value = txtDatabaseTicketNo.Text
dbComm.Parameters.Add("@FixedRev", OleDbType.Currency).Value = txtFixedRev.Text
dbComm.CommandText = "SP_UpdateFixedRev"
dbComm.CommandType = CommandType.StoredProcedure
dbComm.ExecuteNonQuery()
dbConn.Close()

However its not updating my database when I run the app from a button click event.

View 7 Replies View Related

SQL 2012 :: Execute Multiple Queries And Email

Jul 14, 2014

I have to create a SQL job which will run around 50 queries and email results when the query gets some results.These are like quality checks which run to check errors in the system so if any query(out of 50 queries) returns some results an email with the details will be sent .So if 5 queries return results 5 emails with the details will be sent .

I think of something like A table which has one column as the query .What will be the best way of handling such a scenario , may be need an SSIS package with steps ?

View 3 Replies View Related

Execute Multiple SQL Statements In Stored Procedur

Feb 28, 2008

I am seeking a syntax example for executing multiple T-SQL statements in a single stored procedure. For example, I would like to insert a new client record and immediately insert an associated household record. I don't want to have to hit the database twice to accomplish this, and I prefer not to use a trigger.

View 1 Replies View Related

Best Practices Question - How Do You Execute Multiple Packages?

Jan 26, 2006

I have 200+ plus packages that need to be flexible in how they are run. For example, an end user may choose to run packages 1,2,3 and the next end user may choose to run packages 2,3,7, etc. Prior ro running a package, I set an "instance id" inside the group of packages so I can tie them all together in the logfile - I know that packages 1,2,3 were all run as group and that's distinct from packages 2,3,7 that were run in a differnt group.

Initially I embarked on a scenario where I had a queue table that loaded up the packages to be run and then had a little c# app that read the queue, generated the "instance id" and ran all the packages (either thru dtexec.exe or the Microsoft.SqlServer.DTS.Runtime). But now I wonder if using a master package that uses the Execute Package Task is the way to go. My 200+ packages are all independent and run based on a single config file and it seems as though going the parent package route will destroy some of that independence because I'll now be relying on parent package variables.

Any comments or suggestions?

View 2 Replies View Related

DTS - Using Multiple Stored Procedures In One Execute SQL Task

Jan 3, 2008

I'm running this legacy DTS package under SQL Server 2005, and need to make some changes.

I have some (say, 3) stored procedures, and they all have one same parameter. Each SP returns a dataset. I need to import each dataset to a table using DTS. Both the SPs and the destination tables are in the same database.


So, I created an "Execute SQL Task" and typed in "SQL Statement" something like this:


INSERT INTO TABLE TABLE1
EXEC SP1 ?
GO
INSERT INTO TABLE TABLE2
EXEC SP2 ?
GO
INSERT INTO TABLE TABLE3
EXEC SP3 ?
GO


And the execution returns an error: No value given for one or more required parameters.


Is it possible to assign a parameter to all three SPs? What is the work out if I don't want to change the SPs, and I don't want to create 3 Execute SQL Tasks?

View 4 Replies View Related

Loading Multiple Variables From Within The Same Execute Sql Task

Aug 28, 2007

Hi All,

I was wondering if it is possible to assign values to multiple variables from within the same execute sql task, ie I want to use only one execute sql task and have multiple T-SQL statements within it and then assign the results of these sql statemenst as values to multiple variable.

Typically I would declare variables var1 , var2 and var3 , then can I just add one execute sql task and have mutiple sql statements within it? something like this

select max(id) from table1

select max(id) from table2

select max(id) from table3

Thanks

View 3 Replies View Related

Integration Services :: How To Execute Multiple Packages In Parallel

Oct 14, 2008

I'm pretty new to SSIS but I've managed to cobble together a number of individual packages to refresh SQL tables from a 3rd-party database.
 
Now, what I'd like to do is have a single package that I can use to invoke each of the individual ones. Since it will run on a quad, I'd like to invoke them such they'll run in parallel.

View 2 Replies View Related

Unable To Execute Multiple SSIS Packages From Windows Service

Aug 28, 2007

Need some help...
When we tried to run mulitple packages one after the other from a windows service, first one succeeds but later ones are throwing below error :
"The script threw an exception: The element cannot be found in a collection. This error happens when you try to retrieve an element from a collection on a container during execution of the package and the element is not there.
A deadlock was detected while trying to lock variable "System:ackageName, User::BusinessDate, User::Environment, User:ortfolioName" for read access. A lock could not be acquired after 16 attempts and timed out."

Later, we tried to create separate AppDomains for each package and execute via console application, but ended up with below error (The below expressions were defined in OnError Event) :
"The result of the expression "@[User::ReportErrorFrom]" on property "FromLine" cannot be written to the property. The expression was evaluated, but cannot be set on the property.
The result of the expression ""Error At :" + @[System:ourceName] + "" +
"Error Description : "+ @[System::ErrorDescription] + "" " on property "MessageSource" cannot be written to the property. The expression was evaluated, but cannot be set on the property."

At last, we tried to span a separate process (System.Diagnostics.Process) for each package. this seems working but taking very long time:
A package that normally takes 2 min, is taking 60 min.

We also tried creating an SSIS Package that executes mulitple packages. But only first package is getting executed, and second one is throwing below error (Here the variable it is trying to lock is of first package):
"Failed to lock variable "UniqueInstrumentsQuery1" for read access with error 0xC0010001 "The variable cannot be found. This occurs when an attempt is made to retrieve a variable from the Variables collection on a container during execution of the package, and the variable is not there. The variable name may have changed or the variable is not being created.".

Please help us with some work around for this. Thanking you in advance,

View 17 Replies View Related

Integration Services :: SSIS Execute Multiple Packages Based On Conditional Split

Sep 4, 2015

We are building a dataload application where parameters are store in a table. And there are multiple packages for each load.There is a column IsChecked column if it is 1 then only the child package should execute.Created a master package. In which i have taken execute SQL task in that storing a results in variable and based on the result the child package should execute. But In executesql task i selected result set as full result set.  I am getting the below error.

[Execute SQL Task] Error: Executing the query "SELECT  isnull(ID ,0) AS ID FROM DataLoadParameter..." failed with the following error: "The type of the value (DBNull) being assigned to variable "User::LoadValue" differs from the current variable type (Int32). Variables may not change type during execution. Variable types are strict, except for variables of type Object.". Possible failure reasons: Problems with the query, "ResultSet" property not set correctly, parameters not set correctly, or connection not established correctly.

View 3 Replies View Related

Creating A Database From Multiple Databases Accross Multiple Servers

Sep 13, 2007

Hi,

I'm trying to create a database that takes specific information from a number of databases on different servers to make some reporting that we have much easier.

I'm pretty new to SQL so I'm not sure of the best way to proceed. I read an article that suggested I use the OPENROWSET command. The problem is, the version of SQL that came with one of the programmes we use is limited and will not allow you to turn on the allow "Ad Hoc distributed Queries" so the SLQ statement will not execute.

I'm confused why it won't let me to connect through ODBC as I've created a web page that selects data from this database with no problems!

Here is the SQL statement that I've written to make sure it is the correct one (on the msdn library page it said that this was the ODBC connection):

SELECT a.*
FROM OPENROWSET('MSDASQL','DRIVER=(SQL Server);SERVER=APPOLOACT7;UID=sa;PWD=***************',
'SELECT * FROM MDCTestAndDev.dbo.TBL_CONTACT') AS a



I've also created the ODBC connection using the tool on Administration Tools>Data Sources ODBC

Any help would be greatly appreciated (also any ways of selecting from one database and inserting it into another will be helpfull)

Thanks

View 8 Replies View Related







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