Respondido variable datatype

  • Tuesday, February 28, 2012 7:27 AM
     
     

    HI

      i used execute sql task in my package so in that i wrote a query like this

    select max(id) as id from dim_table

    my id column is in number datatype

    i used resultset to get this data

    but in that varaible type i choose int32 means

    its shows error like this

    [Execute SQL Task] Error: An error occurred while assigning a value to variable "ID": "The type of the value being assigned to variable "User::ID" differs from the current variable type. Variables may not change type during execution. Variable types are strict, except for variables of type Object.
    ".

    so which datatype i want to choose in my varible

All Replies

  • Tuesday, February 28, 2012 7:32 AM
    Moderator
     
     Proposed Has Code
    Maybe you can add a CAST in your query:
    select CAST(max(id) as int) as id from dim_table


    Please mark the post as answered if it answers your question | My SSIS Blog: http://microsoft-ssis.blogspot.com

  • Tuesday, February 28, 2012 7:36 AM
     
     

    HI

      i used execute sql task in my package so in that i wrote a query like this

    select max(id) as id from dim_table

    my id column is in number datatype

    i used resultset to get this data

    but in that varaible type i choose int32 means

    its shows error like this

    [Execute SQL Task] Error: An error occurred while assigning a value to variable "ID": "The type of the value being assigned to variable "User::ID" differs from the current variable type. Variables may not change type during execution. Variable types are strict, except for variables of type Object.
    ".

    so which datatype i want to choose in my varible

    You use SingleRow option as you are getting only one value which is Max

    Murali


    • Edited by Murali_CHN Tuesday, February 28, 2012 7:40 AM
    •  
  • Tuesday, February 28, 2012 7:49 AM
     
     

    Ya i tried that still i m getting that same error..

  • Tuesday, February 28, 2012 7:50 AM
     
     

    You have 2 options:

    1. If you want output in resultset then you need to use Object datatype in variables.

    2. You can use Stored proc and in that use the ID variable as Output Parameter. Set the Variables as number datatype and you will not get any error.

    Let me know if you still faces the issue after you made the changes.

  • Tuesday, February 28, 2012 7:50 AM
     
     
    Shall i explain me  briefly
    • Edited by sql.anandan Tuesday, February 28, 2012 7:51 AM
    •  
  • Tuesday, February 28, 2012 8:03 AM
     
     

    The resultset option in the General tab should be SingleRow. Kindly check it

  • Tuesday, February 28, 2012 8:07 AM
    Moderator
     
     

    Ya i tried that still i m getting that same error..


    What's your result set type? (See general tab)

    Please mark the post as answered if it answers your question | My SSIS Blog: http://microsoft-ssis.blogspot.com

  • Tuesday, February 28, 2012 8:08 AM
     
     
    Ya that's in Single row only then only result set window will enable..
  • Tuesday, February 28, 2012 8:16 AM
     
     
    Ya that's in Single row only then only result set window will enable..

    It should work. Not sure what could be the problem. Let's see if somebody else has better solutions.

    Murali

  • Tuesday, February 28, 2012 8:43 AM
     
     Answered
    ya thanks for all... in that general tab  bypassprepare i set as false now its working very thanks for ur reply's