Search
 
SCRIPT & CODE EXAMPLE
 

SQL

functions with parameters SQL

USE tempdb;
GO

DROP FUNCTION IF EXISTS dbo.GetOrderID;
DROP TABLE IF EXISTS OrdersTest;
GO

CREATE TABLE OrdersTest (OrderID int IDENTITY, OrderType int, Qty int, ServiceSpeed int);
GO

CREATE FUNCTION GetOrderID
(
	@OrderType int = 0,
	@ServiceSpeed int = 0,
	@Qty int = 0
)
RETURNS int AS
BEGIN
	RETURN
	(
		SELECT
			TOP 1 OrderID
		FROM		OrdersTest
		WHERE		OrderType = @OrderType
		AND			ServiceSpeed = @ServiceSpeed
		AND			Qty = @Qty
		
	);
END
GO
Comment

functions with parameters SQL

SET @OrderID = dbo.GetOrderID (default, default, default);
Comment

functions with parameters SQL

EXEC @OrderID = dbo.GetOrderID
	@OrderType = @OrderType,
	@ServiceSpeed = @Qty,
	@Qty = @ServiceSpeed;
Comment

PREVIOUS NEXT
Code Example
Sql :: how to install mysql 8.0 windows service 
Sql :: mysql on duplicate key ignore 
Sql :: truncate table in sql 
Sql :: oracle create tablespace autoextend 
Sql :: sql order by two columns 
Sql :: update multiple columns in sql 
Sql :: read xml in sql server 
Sql :: between vs in sql 
Sql :: ms sql print more than 1 variable 
Sql :: mysql expression is not in group by clause 
Sql :: truncate table sqlite 
Sql :: mysql datetime format 
Sql :: linux bash run sql command 
Sql :: how to insert a uniqueidentifier in sql 
Sql :: sqlite get date only 
Sql :: execut sql python 
Sql :: initcap in sql 
Sql :: change column name sql 
Sql :: how to get max salary in each department in sql 
Sql :: oracle get foreign keys on table 
Sql :: sql composite key 
Sql :: mysql on kubernetes 
Sql :: unique element in sql 
Sql :: mysql filter by date mount 
Sql :: postgres full text search example 
Sql :: sql or 
Sql :: mysql workbench format date 
Sql :: SQL AVG() Function 
Sql :: sqlite create record 
Sql :: insert using condition postgres 
ADD CONTENT
Topic
Content
Source link
Name
2+4 =