Showing posts with label returns. Show all posts
Showing posts with label returns. Show all posts

Friday, March 23, 2012

it maybe a wrong return value

There is a sql function like this below:
Create Function dbo.abc
(@.ParamOne decimal, @.ParamTwo decimal)
RETURNS Bit
AS
BEGIN
DECLARE @.Result bit
if abs(@.ParamOne-@.ParamTwo)<0.01
SET @.Result=1
else
SET @.Result=0
RETURN @.Result
END
if i execute this sentence: "select dbo.abc (2.12,2.11)" , why does the
function return 1 instead of 0?
Thanks.
Lorry
Please give the precision and scale while using decimal. See the below
example.
ALTER Function dbo.abc
(@.ParamOne numeric(10,2), @.ParamTwo numeric(10,2))
RETURNS Bit
AS
BEGIN
DECLARE @.Result bit
if abs(@.ParamOne-@.ParamTwo)<0.01
SET @.Result=1
else
SET @.Result=0
RETURN @.Result
END
Thanks
Hari
"Lorry Astra" <LorryAstra@.discussions.microsoft.com> wrote in message
news:A86A320C-192C-4321-A4D4-05B32ADC3BD1@.microsoft.com...
> There is a sql function like this below:
> Create Function dbo.abc
> (@.ParamOne decimal, @.ParamTwo decimal)
> RETURNS Bit
> AS
> BEGIN
> DECLARE @.Result bit
> if abs(@.ParamOne-@.ParamTwo)<0.01
> SET @.Result=1
> else
> SET @.Result=0
> RETURN @.Result
> END
> if i execute this sentence: "select dbo.abc (2.12,2.11)" , why does the
> function return 1 instead of 0?
> Thanks.
>
> Lorry

Monday, March 12, 2012

Issue with the ForEachLoop Task in SSIS


Hi,


I am using a SQL task to execute a stored procedure which returns a single field with multiple records. I want the records returned by the stored procedure to be processed one by one within a ForEachLoop container. How do I assign the records one by one to one variable and use it in a Script task running inside the ForEachLoop container.


I am using 2 tasks in my package.


In my first task I call a SQL task that executes a stored procedure which returns a list of reference numbers (TrackData). This works perfectly.


However, in my second task I must use the ForEachLoop task to loop through the above list and set the value of var_TrackData (a user variable declared by me) with the value of the TrackData present in it during that particular loop.


I am not sure how to go about the second task. Any help would be greatly appreciated.

Create an object variable.

In the execute sql task set the resultset to the variable name (set result name to 0).

Create a variable to hold the reference numbers (int or string?)

Create a for each loop task

Set the collection to for each ADO enumerator

Set the ADO object source variable to your object variable name (which contains the resultset).

In variable mappings set the variable to the variable name you created to hold the reference numbers

Set the precednce so that the execute sql runs before the for each llop.

Now when this runs the object variable will be set to the resultset the the for each loop will itterate through it setting the variable to the reference number for each loop.

|||

See if this post gives you some idea of how you can do it:

http://rafael-salas.blogspot.com/2006/12/import-header-line-tables-into-dynamic_22.html

Issue with sorting reports

Hi,

I'm having an issue with sorting reports. I have an order by in the query which returns the results how I want them, but if I use the auto generated columns and layout they are not in the order that the query returns them. However, if I manually create a new table and put the results in that they are ordered fine.

I am having this problem in reporting services for sql 2000, but my workmate has had exactly the same thing in his reporting for 2005.

Any help would be greatly appreciated.

Rob

What is the auto generated columns and layout?|||

How can you auto generate columns in sql reporting table? Are you using Visibility expression for the columns in the table to make it look dynamic? Can you provide the query and the report layout you have along with the explanation of the problem?

Shyam