Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
AdamWest
Constraint Violating Yak Guru
360 Posts |
Posted - 2010-07-27 : 22:06:31
|
| HI this function I want to run and see if it is returning data, i think it is not is this the way to do so?exec _FnGetBudgetAmount '2010', 'NM01', 'Gloves'the function code is here:USE [SUPPL_MINI]GO/****** Object: UserDefinedFunction [dbo].[_FnGetBudgetAmount] Script Date: 07/27/2010 19:19:31 ******/SET ANSI_NULLS ONGOSET QUOTED_IDENTIFIER ONGO -- ============================================= -- Author: <Author,,Name> -- Create date: <Create Date, ,> -- Description: <Description, ,> -- ============================================= ALTER FUNCTION [dbo].[_FnGetBudgetAmount] ( -- Add the parameters for the function here @Year Date, @CustNMBR varchar(100), @USCATVAL varchar(100) ) RETURNS float AS BEGIN -- Declare the return variable here DECLARE @ResultVar float set @ResultVar = 0 -- Add the T-SQL statements to compute the return value here SELECT @ResultVar = isnull( [BudgetAmount],0) FROM [dbo].[CustomerBudget] Where (@Year between BudgetDateFrom and BudgetDateTo) and CUSTNMBR = @CustNMBR and [USCATVAL] = @USCATVAL AND Dept = 'Medical' -- Return the result of the function RETURN @ResultVar END |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2010-07-27 : 22:11:04
|
for function you don't execcute it, you SELECT itselect [dbo].[_FnGetBudgetAmount] ('2010', 'NM01', 'Gloves') KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
slimt_slimt
Aged Yak Warrior
746 Posts |
Posted - 2010-07-28 : 01:34:46
|
I would just add:USE [SUPPL_MINI]GOSELECT [dbo].[_FnGetBudgetAmount] ('2010', 'NM01', 'Gloves') |
 |
|
|
|
|
|
|
|