Solved

Autofill an identitly field using an activex script in DTS

Posted on 2003-12-11
4
294 Views
Last Modified: 2008-03-04
I have a vbscript that copies and transforms data from an access table to and existing MSSQL table. The destination table has an identity column, and I need to autopopulate it as the data is loaded. I'm thinking the line of code would look something like:

DTSDestination("id") = ?

where ? is a command to autoincrement the id by 1. Hopefully this is just a syntax question. Thanks.
0
Comment
Question by:dsachtleben
  • 3
4 Comments
 
LVL 30

Expert Comment

by:nmcdermaid
Comment Utility
Use the DTS Package Properties dialog to create a global variable. This global variable can then be accessed in code.


For example:


Function Main()
   DTSDestination("FieldName") = DTSGlobalVariables("NewID").value
   DTSGlobalVariables("NewID").value = DTSGlobalVariables("NewID").value + 1
   Main = DTSTaskExecResult_Success
End Function



0
 
LVL 30

Accepted Solution

by:
nmcdermaid earned 125 total points
Comment Utility
PS a SQl Server IDENTITY column automatically fills in this incremental value
0
 

Author Comment

by:dsachtleben
Comment Utility
Thanks for help! I am obviously new to DTS but this was a very clear solution.
0
 
LVL 30

Expert Comment

by:nmcdermaid
Comment Utility
Don't get too familiar! It will probably change next version of SQL Server! than again that is a couple of years away.

There are a lot of handy exmpaples here: SQLDTS.COM
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Suggested Solutions

In this article—a derivative of my DaytaBase.org blog post (http://daytabase.org/2011/06/18/what-week-is-it/)—I will explore a few different perspectives on which week today's date falls within using Microsoft SQL Server. First, to frame this stu…
Let's review the features of new SQL Server 2012 (Denali CTP3). It listed as below: PERCENT_RANK(): PERCENT_RANK() function will returns the percentage value of rank of the values among its group. PERCENT_RANK() function value always in be…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Viewers will learn how the fundamental information of how to create a table.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now