SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
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  

jamios28
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?

thx

==============================================================
CREATE FUNCTION dbo.CurrencyConvert(@StartCurrency Char, @Subtotal Real,@DateDelivered DateTime)
RETURNS Real
As
BEGIN

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


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

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

RETURN @Result

end

nr
SQLTeam MVY

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

jsmith8858
Dr. Cross Join

USA
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.06 seconds. Powered By: Snitz Forums 2000