Pass Collection to Function or Procedure

0

Category :


IF EXISTS (SELECT * FROM sys.types WHERE is_table_type = 1 AND name = 'TestPassList')
 DROP TYPE TestPassList
GO

CREATE TYPE dbo.TestPassList
AS TABLE
(
 BookingIdMaster INT,
 BookingId  INT
);
GO


CREATE PROCEDURE sp_TestPassList
  @List AS dbo.TestPassList READONLY
AS
BEGIN
 SELECT *
  FROM @List

END
GO


IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'fn_TestPassList') AND type in (N'P', N'TF'))
 DROP FUNCTION fn_TestPassList
GO

CREATE FUNCTION fn_TestPassList(@List AS dbo.TestPassList READONLY)
RETURNS @temptable 
 TABLE (  
   BookingId INT
 )       
AS 
BEGIN 
  
 INSERT INTO @temptable    
  SELECT BookingId
  FROM @List
 
 RETURN      
END
GO

----------- test
DECLARE @TestPassListVar dbo.TestPassList
INSERT INTO @TestPassListVar 
SELECT TOP 10 billing_id Booking_IdMaster,
    Booking_Id
 FROM d_booking
 
SELECT * 
 FROM fn_TestPassList(@TestPassListVar)
 

SOLID: Part 4 - The Dependency Inversion Principle

0

Category :

Definition

  • A. High-level modules should not depend on low-level modules. Both should depend on abstractions.
  • B. Abstractions should not depend upon details. Details should depend upon abstractions.


my thanks to:
http://code.tutsplus.com/tutorials/solid-part-4-the-dependency-inversion-principle--net-36872

Pivot - SQL Server

0

Category :

“Pivot is a sql server operator that can be used to turn unique values from one column, into multiple columns in the output, there by effectively rotating a table”. Column values are converted into column names

Read Pivot Statement

We are performing this aggregate function on the 1st column for 2nd column for column in “in”



Represented in cross tab format…

my thanks to: http://www.youtube.com/watch?v=h3BtudZehuo

SOLID: Part 3 – Liskov Substitution & Interface Segregation Principles

0

Category : ,

http://net.tutsplus.com/tutorials/php/solid-part-3-liskov-substitution-interface-segregation-principles/

Subtypes must be substitutable for their base types.