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

TypeScript Error Or Bug: The term 'tsc' is not recognized as the name of a cmdlet, function, script file, or operable program.

Invalid nested tag div found, expected closing tag input