Please start any new threads on our new site at We've got lots of great SQL Server experts to answer whatever question you can come up with.

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
Register Now and get your question answered!
Save Password
Forgot your Password?

 All Forums
 Old Forums
 CLOSED - General SQL Server
 my first function error
 Forum Locked
 Printer Friendly
Author Previous Topic Topic Next Topic  

Starting Member

18 Posts

Posted - 03/30/2005 :  10:59:19  Show Profile

just wanted ur thoughts and do i need a begin at the start of each if?


CREATE FUNCTION dbo.CurrencyConvert(@StartCurrency Char, @Subtotal Real,@DateDelivered DateTime)

DECLARE @Result Real , @DateTemp DateTime, @ExRate real
Set @DateTemp = @DateDelivered
WHILE (SELECT DateTx FROM Exchange WHERE Exchange.DateTx = @DateTemp) = 0
Set @DateTemp = @DateTemp + 1

SELECT ExchRate2 from Exchange WHERE Exchange.DateTx = @DateTemp
Set @ExRate= ExchRate2

IF CharIndex(@StartCurrency, 'USD') <> 0
SET @Result = @Subtotal * @ExRate
SET @Result = @Subtotal

RETURN @Result



United Kingdom
12543 Posts

Posted - 03/30/2005 :  11:00:59  Show Profile  Visit nr's Homepage
no, only if you have more than one statement - but it's clearer if you do.

Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

Dr. Cross Join

7423 Posts

Posted - 03/30/2005 :  15:45:06  Show Profile  Visit jsmith8858's Homepage
A little constructive critism/advice:

I know you mentioned you are young and you have just started your first job after college, but try to use proper english (more or less) in your questions and posts in forums such as these to be taken seriously. Abbreviations like "ur" and "any1" label you as a script kiddie or an AOL chatter, whether that's accurate or not ... especially in email correspondence at work or technical documentation/notes.

No self-respecting real programmer uses "kewl h4ck3r" lingo like that ... (I actually just learned what "l33t" means just a few weeks ago !)

- Jeff

Edited by - jsmith8858 on 03/30/2005 15:45:59
Go to Top of Page
  Previous Topic Topic Next Topic  
 Forum Locked
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.08 seconds. Powered By: Snitz Forums 2000