Hi Chapmandew
Was close enough and what I was looking for I ended up using
oCmdOutput.CommandType = CommandType.Text
oCmdOutput.CommandText = sSQLUpdate
oCmdOutput.ExecuteNonQuery
Main Topics
Browse All TopicsHi
I have an SSIS script task that builds up a variable that is a SQL server statement. I need ot be able to execute that statement in the script task.
Here is the code I have
Dim oCnn As New Data.SqlClient.SqlConnecti
Dim sSQL As String
Dim sSQLUpdate As String
Dim AccountNumber As String
Dim Nov_07 As String
Dim Sep_07 As String
oCnn.ConnectionString = "Data Source=localhost;Initial Catalog=PAY_HISTORY"
Dim oCmd As SqlCommand = New SqlCommand
sSQL = "SELECT AccountNumber, Sep_07, Nov_07 FROM PAY_HISTORY_Data_temp "
sSQL += "WHERE (AccountNumber IN (SELECT AccountNumber FROM PAY_HISTORY_History)) "
oCmd.CommandText = sSQL
oCmd.Connection = oCnn
oCnn.Open()
Dim oReader As SqlDataReader = oCmd.ExecuteReader()
While oReader.Read
AccountNumber = oReader.Item("AccountNumbe
Nov_07 = oReader.Item("Nov_07").ToS
Sep_07 = oReader.Item("Sep_07").ToS
sSQLUpdate = "update PAY_HISTORY_History set "
sSQLUpdate += "Sep_07='" & Sep_07 & "', "
sSQLUpdate += "Nov_07='" & Nov_07 & "' "
sSQLUpdate += "Where AccountNumber='" & AccountNumber & "'"
'
'******************* Need to execute the above SQL here
'
End While
oReader.Close()
oCnn.Close()
Thanks in advanced.
I would be happy to entertain other ways of doing this as well
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Business Accounts
Answer for Membership
by: chapmandewPosted on 2008-02-21 at 13:03:03ID: 20951830
oCmd.Execute sSQLUpdate