Skip to content

Instantly share code, notes, and snippets.

View samirbehara-zz's full-sized avatar

Samir Behara samirbehara-zz

View GitHub Profile
@samirbehara-zz
samirbehara-zz / LINQImmediateExecution.cs
Created February 13, 2016 17:52
Immediate Execution in LINQ
View LINQImmediateExecution.cs
class ImmediateExecution
{
static void Main(string[] args)
{
var Employees = new List<Employee>
{
new Employee { ID=1 , Name="Samir", Salary=30000 },
new Employee { ID=2 , Name="Robert", Salary=42000 },
new Employee { ID=3 , Name="Peter", Salary=54000 }
};
@samirbehara-zz
samirbehara-zz / JSON Scripts - SQL Server 2016.sql
Created April 30, 2016 21:56
This script contains the examples of JSON usage in SQL Server 2016
View JSON Scripts - SQL Server 2016.sql
-- Return results as a JSON text by using AUTO mode
SELECT TOP 2 [AddressID]
,[AddressLine1]
,[AddressLine2]
,[City]
,[StateProvinceID]
,[PostalCode]
FROM [AdventureWorks2016CTP3].[Person].[Address]
FOR JSON AUTO
@samirbehara-zz
samirbehara-zz / Temporal Tables - SQL Server 2016.sql
Created May 5, 2016 01:35
This script contains the examples demonstrating the usage of Temporal Tables in SQL Server 2016.
View Temporal Tables - SQL Server 2016.sql
-- Creating Temporal table with automatically named History table
CREATE TABLE dbo.Employee
(
EmployeeID int NOT NULL IDENTITY(1,1) PRIMARY KEY CLUSTERED,
EmployeeName varchar(50) NOT NULL,
Age int NULL,
Email nvarchar(50),
ValidFrom datetime2 GENERATED ALWAYS AS ROW START NOT NULL,
@samirbehara-zz
samirbehara-zz / JSON Functions in SQL Server 2016.sql
Created May 14, 2016 17:26
JSON Functions in SQL Server 2016
View JSON Functions in SQL Server 2016.sql
--ISJSON() - To verify that the text has valid JSON data
DECLARE @json nvarchar(max)
SET @json =N'
{
"Person": [
{
"FirstName": "Gustavo",
"LastName": "Achong",
"AccountNumber": "AW00029484",
@samirbehara-zz
samirbehara-zz / Live Query Statistics.sql
Created May 14, 2016 17:46
Live Query Statistics in SQL Server 2016
View Live Query Statistics.sql
-- Script to demonstrate the Live Query Statistics Feature in SQL Server 2016
SELECT * FROM Production.Product PR
INNER JOIN Production.Product_ondisk PO
ON PO.SellStartDate = PR.SellStartDate
--ON PO.ProductSubcategoryID = PR.ProductSubcategoryID
INNER JOIN Production.ProductModel PM
ON PM.ProductModelID = PR.ProductModelID
CROSS APPLY Production.ProductSubcategory PSC
@samirbehara-zz
samirbehara-zz / Compare Execution Plans.sql
Created May 14, 2016 18:04
Compare Execution Plans in SQL Server 2016
View Compare Execution Plans.sql
-- Drop Index if exists
DROP INDEX IF EXISTS [idx_Person_Email_Date] ON [Person].[Person]
-- Execute a query with a missing index
SELECT e.BusinessEntityID FROM HumanResources.Employee e
INNER JOIN Person.Person p
ON p.ModifiedDate = e.ModifiedDate
WHERE p.EmailPromotion = 1
@samirbehara-zz
samirbehara-zz / TSQL Enhancements.sql
Created May 15, 2016 20:29
TSQL Enhancements in SQL Server 2016
View TSQL Enhancements.sql
Use TestDB
-- Before SQL Server 2016
IF EXISTS(SELECT * FROM dbo.Employee)
DROP TABLE dbo.Employee
IF EXISTS(SELECT * FROM SYS.TABLES WHERE NAME ='dbo.Employee')
DROP TABLE dbo.Employee
--------------------------------------------------------------------------------------------------
View SQl Code Snippets.sql
-- Use Code Snippets to generate the syntax of your Non Clustered Index
CREATE UNIQUE NONCLUSTERED INDEX IX_TableName_Col1
ON dbo.TableName
(column_1)
View Dynamic Toggle Functionality - TypeScript
<script src="https://cdnjs.cloudflare.com/ajax/libs/knockout/3.4.2/knockout-min.js"></script>
<select id="switch" data-bind="value: selectedOption">
<option value="option">Select Option...</option>
<option value="invNumber">Invoice Number </option>
<option value="subCode">Subscriber Code </option>
</select>
<br><br>
View Dynamic Toggle Functionality - Javascript
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<select id="switch">
<option value="unknown">Select Option...</option>
<option value="invNumber">Invoice Number </option>
<option value="subCode">Subscriber Code </option>
</select>
<br><br>
<span id="invNumber-input" style="display:none"><input type="text" id="name"></span>