Showing posts with label abc. Show all posts
Showing posts with label abc. 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

Wednesday, March 21, 2012

Issues with Export to Excel file

I need to do a simple task. I have a oledb source which pulls data from sql server, creates an excel file abc.xls and dumps it with the Excel destination at remote location.

I need to create this file at runtime. However, when i give the location, the Excel Destination expects the file to be there for the Mapping of the source columns with destination ones.

My tasks are

1. Creating a table for the worksheet in Excel connection

2. Select from source table and write in Excel Destination

Will appreciate your response.

You can create the xls file at run time without problem; but the file need to exists at design time as SSIS needs to get the metedata from it.

I have a couple of posts that show some examples using excel files; I hope you find them helpful

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