- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
 
 
 
                                       F u n   w i t h   L e g a l   I n f o r m a t i o n   i n   S Q L   S e r v e r : 
 
                                           C o r r e l a t i n g   O f f e r s   a n d   C o u n t e r - o f f e r s 
 
 
 
                                                                   D e m o   m a t e r i a l s 
 
 
 
                                           ( c )   2 0 1 7 ,   M i   L a m b d a ,   M a t i j a   L a h ,   s . p . 
 
 
 
 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
 
 
 
 I .   E s t a b l i s h i n g   t h e   e n v i r o n m e n t 
 
 
 
     1 .   I n s t a l l   t h e   W i d e W o r l d I m p o r t e r s   S Q L   S e r v e r   2 0 1 6 +   s a m p l e   d a t a b a s e .   Y o u   c a n 
 
     d o w n l o a d   i t   f r o m   G i t H u b   ( h t t p s : / / g i t h u b . c o m / M i c r o s o f t / s q l - s e r v e r - s a m p l e s ) . 
 
 
 
     2 .   C r e a t e   a   n e w   f o l d e r ,   f o r   i n s t a n c e   i n   t h e   C :   d r i v e   o f   y o u r   m a c h i n e ,   w i t h   t h e 
 
     n a m e   " S Q L C L R " . 
 
 
 
     3 .   C o p y   t h e   " L e g a l . U t i l i t y . S q l C l r . d l l "   S Q L   C L R   a s s e m b l y   f i l e   t o   t h e   f o l d e r 
 
     c r e a t e d   i n   s t e p   2 .   I f   y o u ' v e   u s e d   a   d i f f e r e n t   f o l d e r ,   y o u   w i l l   h a v e   t o   a d j u s t 
 
     t h e   s c r i p t   i n   s t e p   5   ( t h a t   i s ,   t h e   c o m m a n d   u s e d   t o   c r e a t e   t h e   a s s e m b l y ) . 
 
 
 
     4 .   C o p y   t h e   r e s t   o f   t h e   s a m p l e   f i l e s   t o   a   f o l d e r   o f   y o u r   c h o i c e . 
 
 
 
     5 .   I n   S S M S ,   c o n n e c t   t o   t h e   W i d e W o r l d I m p o r t e r s   d a t a b a s e ,   c a r e f u l l y   r e v i e w ,   a n d 
 
     t h e n   e x e c u t e ,   t h e   f o l l o w i n g   s c r i p t s   t o   c r e a t e   t h e   d a t a b a s e   o b j e c t s : 
 
 
 
         -   " 1 1 _ L e g a l _ O f f e r s _ O b j e c t s _ S c r i p t . s q l " ;   a n d 
 
         -   " 1 1 c _ L e g a l _ O f f e r s _ P r o c e d u r e s _ S c r i p t . s q l " . 
 
         
 
     6 .   I n   S S M S ,   w h i l e   c o n n e c t e d   t o   t h e   W i d e W o r l d I m p o r t e r s   d a t a b a s e ,   c a r e f u l l y 
 
     r e v i e w ,   a n d   t h e n   e x e c u t e ,   t h e   f o l l o w i n g   s c r i p t   t o   l o a d   t h e   s a m p l e   d a t a   ( i t 
 
     s h o u l d   c o m p l e t e   i n   f e w   m i n u t e s ) : 
 
     
 
         -   " 1 2 _ L e g a l _ O f f e r s _ D a t a _ S c r i p t . s q l " . 
 
         ( C h a n g e   t h e   n u m b e r   a f t e r   t h e   G O   c o m m a n d   t e r m i n a t i n g   t h e   d a t a   p r e p a r a t i o n 
 
         b a t c h e s   t o   c h a n g e   t h e   n u m b e r   o f   r o w s   i n   t h e   t a b l e s . ) 
 
 
 
     7 .   R u n   t h e   f o l l o w i n g   s c r i p t   t o   a d d   m a t c h i n g   c a s e s   ( t h i s   i n c r e a s e s   t h e 
 
     p r o b a b i l i t y   o f   a   m a t c h ) : 
 
     
 
         -   " 1 3 _ L e g a l _ O f f e r s _ A d d i t i o n a l D a t a _ S c r i p t . s q l " . 
 
         ( Y o u   c a n   a l s o   r u n   t h i s   s c r i p t   a f t e r   y o u   h a v e   r u n   t h e   q u e r i e s   i n   s e c t i o n   I I . ) 
 
 
 
 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
 
 
 
 I I .   R u n n i n g   t h e   q u e r i e s 
 
 
 
     1 .   U s e   t h e   f o l l o w i n g   s c r i p t   t o   p e r f o r m   t h e   q u e r i e s : 
 
 
 
         -   " 1 4 _ L e g a l _ O f f e r s _ D e m o _ S c r i p t . s q l " . 
 
 
 
     2 .   M a k e   c h a n g e s   t o   t h e   W H E R E   c l a u s e   o f   t h e   C o r r e l a t e d O f f e r s   c o m m o n   t a b l e 
 
     e x p r e s s i o n ,   a n d   o b s e r v e   h o w   t h e y   a f f e c t   t h e   e x e c u t i o n   p l a n ,   a n d   t h e   q u e r y 
 
     p e r f o r m a n c e . 
 
     
 
     3 .   U s e   t h e   f o l l o w i n g   s c r i p t   t o   a d d   c a s e s   t o   t h e   c o l l e c t i o n ,   a n d   t h e n   p e r f o r m 
 
     s t e p s   I I . 1   a n d   I I . 2   a g a i n . 
 
     
 
     4 .   A d d   t h e   r o w s t o r e   c o l u m n s   t o   t h e   t a b l e s   b y   u s i n g   t h e   f o l l o w i n g   s c r i p t   ( u s e 
 
     t h e   c o m m a n d s   i n   t h e   C l e a n   u p   s e c t i o n   t o   r e m o v e   a n y   e x i s t i n g   i n d e x e s ) : 
 
     
 
         -   " 1 1 a _ L e g a l _ O f f e r s _ R o w s t o r e I n d e x e s _ S c r i p t . s q l " . 
 
 
 
     5 .   E x e c u t e   s t e p s   I I . 1   a n d   I I . 2   a g a i n ,   a n d   o b s e r v e   w h e t h e r   a n d   h o w   t h e   i n d e x e s 
 
     a r e   u s e d . 
 
     
 
     6 .   A d d   t h e   c o l u m n s t o r e   c o l u m n s   t o   t h e   t a b l e s   b y   u s i n g   t h e   f o l l o w i n g   s c r i p t 
 
     ( u s e   t h e   c o m m a n d s   i n   t h e   C l e a n   u p   s e c t i o n   t o   r e m o v e   a n y   e x i s t i n g   i n d e x e s ) : 
 
     
 
         -   " 1 1 b _ L e g a l _ O f f e r s _ C o l u m n s t o r e I n d e x e s _ S c r i p t . s q l " . 
 
 
 
     7 .   E x e c u t e   s t e p s   I I . 1   a n d   I I . 2   a g a i n ,   a n d   o b s e r v e   w h e t h e r   a n d   h o w   t h e   i n d e x e s 
 
     a r e   u s e d . 
 
 
 
 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
 
 