Pass SQL Execute task output to target tbl(Data flow).

  • Hi,

    we need to insert random values to target table.

    We are using the query in SQL Execute task with single row result set & in the Result Set tab set with user variable(intRdmid).

    declare @PriID int

    select top 1 @PriID = code_id from Pri_codes_master where code_desc like '%assignment%'

    ORDER BY NEWID()

    select @PriID

    But getting error as...

    [Execute SQL Task] Error: An error occurred while assigning a value to variable "intRdmid": "Unable to find column @PriID in the result set.".

    I want to use this value in data flow task to insert in target table.How can I implement this?

    can anyone tell me please ?

    Thanks,

  • You've made it more complex than it needs to be - no need for the SQL Server variable. Just this should be fine:

    select top 1 code_id from Pri_codes_master

    where code_desc like '%assignment%'

    ORDER BY NEWID()

    By the way - I am presuming that the NEWID() is there to enforce a degree of randomness? Seems like an unusual requirement ...

    If you haven't even tried to resolve your issue, please don't expect the hard-working volunteers here to waste their time providing links to answers which you could easily have found yourself.

  • Thanks for your reply,

    But I want to insert below selected values to another table by random way.

    Ex:

    select Distinct code_id from Pri_codes_master

    where code_description like '%assignment%'

    --ORDER BY NEWID()

    Cod_id values are...

    372

    373

    374

    375

    376

    when we use below query only one (374) inserting to target tbl column.

    select top 1 code_id from Pri_codes_master

    where code_desc like '%assignment%'

    ORDER BY NEWID()

    Hope that i have mentioned issue clearly.

    Please let me if any workaround to achieve.

    Thanks.

  • If you need multiple rows you chnage result set to full and use an object type variable to hold the ado resultset .

    ----------------------------------------------------------------------------------------------------------------------------------------------------
    Roshan Joe

    Jeff Moden -Forum Etiquette: How to post data/code on a forum to get the best help[/url]

  • Saintmount.Sql (12/3/2012)


    Thanks for your reply,

    But I want to insert below selected values to another table by random way.

    Ex:

    select Distinct code_id from Pri_codes_master

    where code_description like '%assignment%'

    --ORDER BY NEWID()

    Cod_id values are...

    372

    373

    374

    375

    376

    when we use below query only one (374) inserting to target tbl column.

    select top 1 code_id from Pri_codes_master

    where code_desc like '%assignment%'

    ORDER BY NEWID()

    Hope that i have mentioned issue clearly.

    Please let me if any workaround to achieve.

    Thanks.

    OK - what I should have said is that you can use a query as your datasource inside a dataflow. No need for an ExecuteSQL task at all.

    If you haven't even tried to resolve your issue, please don't expect the hard-working volunteers here to waste their time providing links to answers which you could easily have found yourself.

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply