Donate

SQL Server Function To Return Amount As Decimal

Here's a simple function that will return the freight amount in decimal format.
use Your_Database_Name  
 if object_id (N'dbo.getFreightValue', N'FN') is not null  
 drop function getFreightValue  
 go  
 create function getFreightValue  
 (  
   @salesID nvarchar(50)  
 )  
 returns decimal(10,2)   
 as  
 begin   
 declare @result varchar(50)   
 set @result =   
 (  
   select Freight   
     from dbo.Orders  
   where OrderID = @salesID   
 )  
 return @result  
 end  
 go  
 -- run function  
 -- select dbo.getSomeValue(10248) as freight_value;  
Cheers!

Comments

Donate

Popular Posts From This Blog

WPF CRUD Application Using DataGrid, MVVM Pattern, Entity Framework, And C#.NET

How To Test Or Check Dead Pixels And Backlight Bleed On Your Monitor Using Dead Pixel Checker In Windows 11

How To Insert Or Add Emojis In Microsoft Teams Status Message