I am being forced to put a @noparameter varchar(1)=null in this function? How do I create a function to return a table which has no parameters!
ALTER FUNCTION [dbo].[DropDownIndividuals](@noparameter varchar(1)=null) RETURNS @IndividualsList TABLE( Case_Number VARCHAR(11) ,LastName VARCHAR(100) ,FirstName VARCHAR(100) ,Midlename VARCHAR(100) ,FullName VARCHAR(100) ) AS BEGIN INSERT INTO @IndividualsList SELECT DISTINCT cast(Case_Number as varchar(10))as Case_Number ,[Lastname] ,[Firstname] ,[Middlename] ,rtrim([Lastname]+ ' '+ [Firstname]) as FullName FROM [MHMODSSQL1P].[ODS].[dbo].[Contact] WHERE [LastName] is not null and [FirstName] is not null UNION ALL SELECT null,null,null,null,null ORDER BY [LastName] RETURN END;
How to Create a Function Without a Parameter in SQL. Line one creates a function then named the function “YTDSALES()”. You can give your function any name. Remember to add parenthesis to the name of the function when without a parameter.
The simplest kind of SQL Server stored procedure that you can call is one that contains no parameters and returns a single result set. The Microsoft JDBC Driver for SQL Server provides the SQLServerStatement class, which you can use to call this kind of stored procedure and process the data that it returns.
Yes you can definitely write User defined function without parameter.
1) You cannot call a PROCEDURE from SQL only a function. You have the above defined as a function but it doesn't return anything sensible. 2) you cannot call a function that has an OUT parameter -- only in parameters are allowed in SQL. Your solution is easy -- use a function that returns the number.
FUNCTION [dbo].[DropDownIndividuals]()
You can just use open and close brackets to define function without parameters, Assuming you are using SQL server.
You should be a able to do it with something like this:
ALTER FUNCTION [dbo].[DropDownIndividuals]()
But since a table-valued function is essentially a parameterised view, you might as well just use a view rather than a TVF with no parameters:
CREATE VIEW [dbo].[DropDownIndividuals]
AS
SELECT -- etc
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With