Solved

Autofill an identitly field using an activex script in DTS

Posted on 2003-12-11
4
295 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

Control application downtime with dependency maps

Visualize the interdependencies between application components better with Applications Manager's automated application discovery and dependency mapping feature. Resolve performance issues faster by quickly isolating problematic components.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
MS SQL Inner Join - Multiple Join Parameters 2 19
How to use Full Text CONTAINS with Case in SQL 6 18
Sql Count with Select Distinct 4 26
Sql Join Problem 2 32
Introduction In my previous article (http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/SSIS/A_9150-Loading-XML-Using-SSIS.html) I showed you how the XML Source component can be used to load XML files into a SQL Server database, us…
JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties
Via a live example, show how to shrink a transaction log file down to a reasonable size.

910 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

23 Experts available now in Live!

Get 1:1 Help Now