Quantcast
Channel: SQL Server Integration Services forum
Viewing all articles
Browse latest Browse all 24688

Add rows to SQL table with SSIS VB Script

$
0
0

I need to populate a table with a row for each month between a range of dates.

Given one StartDate and one EndDate insert a row for each month between  StartDate and EndDate (inclusive).

E.g.

StartDate = 1/1/2011, EndDate = 12/1/2011 would add 12 rows to the table.

StartDate = 1/1/2011, EndDate = 12/1/2014 would add 48 rows to the table.

Dim cnn As SqlClient.SqlConnection

Dim rst as ?????

        cnn = _

       DirectCast(Dts.Connections("server.DB.conmgr").AcquireConnection(Dts.Transaction),  _

       SqlClient.SqlConnection)

intPrd = dateDiff(month, StartDate, EndDate)

for intCnt = 0 to intPrd

with rst

.AddNew

??? = dateadd(month, intPrd, StartDate)

.update

Next intPrd


Viewing all articles
Browse latest Browse all 24688

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>