dbTalk Databases Forums  

Casting a record count in an expression (SSIS)

microsoft.public.sqlserver.dts microsoft.public.sqlserver.dts


Discuss Casting a record count in an expression (SSIS) in the microsoft.public.sqlserver.dts forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
AT
 
Posts: n/a

Default Casting a record count in an expression (SSIS) - 06-16-2006 , 10:41 AM






Select count(*) as record_count from table1

Have the above sql in a sql task it maps the output to a variable
called "record_count"
which is set up to be scoped to the package.

After the select occurs I am trying to set a precedence constraint
based on whether the count result is greater than zero.

my expression is simple...

@record_count > 0

trouble is that when the sql task executes it will not set the record
count value in the variable. the sql task fails trying to set the
variable.

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

THe above error is when the varaible is int16 datatype. The record
count is natively INT.

If I cast the record count to be varchar and then change the variable
to string it works.

If I convert it to string then my expression must then cast the
variable to an INT to test the value. I then do (DT_I4)@record_count >
0 but I get errors saying it wont convert the value.


TIA


Reply With Quote
  #2  
Old   
Allan Mitchell
 
Posts: n/a

Default Re: Casting a record count in an expression (SSIS) - 06-17-2006 , 09:17 AM






Hello emailwaste (AT) gmail (DOT) com,

Can you not make RECORD_COUNT an INT32 ?

What happens if it blows the upper limit of the INT16 datatype?


Allan

Quote:
Select count(*) as record_count from table1

Have the above sql in a sql task it maps the output to a variable
called "record_count"
which is set up to be scoped to the package.
After the select occurs I am trying to set a precedence constraint
based on whether the count result is greater than zero.

my expression is simple...

@record_count > 0

trouble is that when the sql task executes it will not set the record
count value in the variable. the sql task fails trying to set the
variable.

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

THe above error is when the varaible is int16 datatype. The record
count is natively INT.

If I cast the record count to be varchar and then change the variable
to string it works.

If I convert it to string then my expression must then cast the
variable to an INT to test the value. I then do (DT_I4)@record_count
0 but I get errors saying it wont convert the value.

TIA




Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.