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 Insert Or Add Emojis In Microsoft Teams Status Message

Bootstrap Modal In ASP.NET MVC With CRUD Operations