Create a key in a SSIS package
Hello, I want to create, in a SSIS package, a key 'SK' for a table, this key must continue on the last value (SK), if the table is not empty, for this, I followed the following tutorial http:/ / www.ssistalk.com/2007/02/20/g...urrogate-keys/ I run the first time the key SK is generated normally. But when I run the package again to see if the key value continues on the final value, it turns out that this is not the case, it starts at 1. When I edit the Execute SQL Task, and I generate the application (just before the second run), then I run, I obtain 663 for the value of the variable MaxKey (which is quite logical) but during the second execution (of the package) it is not taken into account, SK starts at 1. I do not know if there is something to configure for the component script to make the right value for the variable MaxKey, this variable appears in the list of ReadOnlyVariables. And thank you in advance.
April 15th, 2011 7:07am

Here is an example of creating an ID in SSIS: http://microsoft-ssis.blogspot.com/2010/01/create-row-id.html Please mark the post as answered if it answers your question | My SSIS Blog: http://microsoft-ssis.blogspot.com
Free Windows Admin Tool Kit Click here and download it now
April 15th, 2011 7:19am

Check this link http://beyondrelational.com/blogs/niteshrai/archive/2010/04/05/incrementing-a-column-value-in-ssis.aspxNitesh Rai- Please mark the post as answered if it answers your question
April 15th, 2011 8:50am

Hi Nitesh,SSISJoost, As Inline with phenomeno1923, what would be the value of the key when the package is rerun which as per the post generated in the script component? Looks like a look up has to be done against the table to check the max id there ?Request to please mark my post as an answer if I helped you to resolve the issue or vote up if I helped you.Thanks. Regards and good Wishes, Deepak.
Free Windows Admin Tool Kit Click here and download it now
April 15th, 2011 8:59am

Hi Nitesh,SSISJoost, As Inline with phenomeno1923, what would be the value of the key when the package is rerun which as per the post generated in the script component? Looks like a look up has to be done against the table to check the max id there ? Request to please mark my post as an answer if I helped you to resolve the issue or vote up if I helped you.Thanks. Regards and good Wishes, Deepak. There is an Execute SQL Task before the Data Flow Task. That Execute SQL Task is getting the max number which is used in the Script Component's PreExecute Method. See the post for more details. Please mark the post as answered if it answers your question | My SSIS Blog: http://microsoft-ssis.blogspot.com
April 15th, 2011 9:05am

Yes, that should do it. Thanks for the correction.Request to please mark my post as an answer if I helped you to resolve the issue or vote up if I helped you.Thanks. Regards and good Wishes, Deepak.
Free Windows Admin Tool Kit Click here and download it now
April 15th, 2011 9:20am

Thank you first I followed the tutorial (only the code changes from the tutorial I followed before), but I still have the same problem in the Execute SQL Task, the variable takes the max after the first run, When I run the second time the key starts at 1 and not by the last value +1. Surely the problem lies in the Data Flow, but I do not know what's the problem exactly. And thank you.
April 15th, 2011 11:03am

You need to read the article(s) more completely. The Execute SQL Task posted above retrieves the current "max" value from the table, and the Script component that's numbering rows inside your Data Flow needs to read that variable as the seed for incrementing new rows. Talk to me now on
Free Windows Admin Tool Kit Click here and download it now
April 15th, 2011 1:03pm

Did you check here?Nitesh Rai- Please mark the post as answered if it answers your question
April 15th, 2011 1:04pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics