Solved

Autofill an identitly field using an activex script in DTS

Posted on 2003-12-11
4
296 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
ID: 9921245
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
ID: 9921260
PS a SQl Server IDENTITY column automatically fills in this incremental value
0
 

Author Comment

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

Expert Comment

by:nmcdermaid
ID: 9921366
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

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Live Storage Vmotion VMs with shared VMDK 10 61
Find SQL query used by application 3 20
TSQL query to generate xml 4 36
Alternative of IN Clause in SQL Server 3 21
Introduction SQL Server Integration Services can read XML files, that’s known by every BI developer.  (If you didn’t, don’t worry, I’m aiming this article at newcomers as well.) But how far can you go?  When does the XML Source component become …
The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

831 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