updated demo doc and snippets
This commit is contained in:
parent
a0a31e16a2
commit
0d0b0b4356
2 changed files with 32 additions and 8 deletions
|
|
@ -4,6 +4,7 @@
|
||||||
-- Description: Test Procedure that shows off language features.
|
-- Description: Test Procedure that shows off language features.
|
||||||
-- Includes non-standard folding using region comments using either
|
-- Includes non-standard folding using region comments using either
|
||||||
-- line comments or block comments (both are demonstrated below)
|
-- line comments or block comments (both are demonstrated below)
|
||||||
|
-- This mode imitates SSMS and it designed to be used with SQL Server theme.
|
||||||
-- =============================================
|
-- =============================================
|
||||||
CREATE PROCEDURE dbo.TestProcedure
|
CREATE PROCEDURE dbo.TestProcedure
|
||||||
|
|
||||||
|
|
@ -27,20 +28,29 @@ BEGIN
|
||||||
* These comments will produce a fold widget
|
* These comments will produce a fold widget
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
-- folding demonstration
|
||||||
SET @vint = CASE
|
SET @vint = CASE
|
||||||
WHEN @vdate IS NULL
|
WHEN @vdate IS NULL
|
||||||
THEN 1
|
THEN 1
|
||||||
ELSE 2
|
ELSE 2
|
||||||
END
|
END
|
||||||
|
|
||||||
|
-- another folding demonstration
|
||||||
IF @vint = 1
|
IF @vint = 1
|
||||||
BEGIN
|
BEGIN
|
||||||
SET @vvarchar='one'
|
SET @vvarchar='one'
|
||||||
SET @vint = DATEDIFFT(dd, @vdate, @vdatetime)
|
SET @vint = DATEDIFFT(dd, @vdate, @vdatetime)
|
||||||
END
|
END
|
||||||
|
|
||||||
|
-- this mode handles strings properly
|
||||||
|
DECLARE @sql nvarchar(4000) = N'SELECT TOP(1) OrderID
|
||||||
|
FROM Orders
|
||||||
|
WHERE @OrderDate > GETDATE()'
|
||||||
|
|
||||||
|
-- this mode is aware of build in stored procedures
|
||||||
|
sp_executesql @sql
|
||||||
|
|
||||||
|
-- demonstrating some syntax highlighting
|
||||||
SELECT Orders.OrderID
|
SELECT Orders.OrderID
|
||||||
,Customers.CompanyName
|
,Customers.CompanyName
|
||||||
,DATEFROMPARTS(YEAR(GETDATE()), 1, 1) AS FirstDayOfYear
|
,DATEFROMPARTS(YEAR(GETDATE()), 1, 1) AS FirstDayOfYear
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ snippet datepart
|
||||||
DATEPART(${1:datepart}, ${2:date})
|
DATEPART(${1:datepart}, ${2:date})
|
||||||
# DATEDIFF
|
# DATEDIFF
|
||||||
snippet datediff
|
snippet datediff
|
||||||
DATEDIFFT(${1:datepart}, ${2:startdate}, ${3:enddate})
|
DATEDIFF(${1:datepart}, ${2:startdate}, ${3:enddate})
|
||||||
# DATEADD
|
# DATEADD
|
||||||
snippet dateadd
|
snippet dateadd
|
||||||
DATEADD(${1:datepart}, ${2:number}, ${3:date})
|
DATEADD(${1:datepart}, ${2:number}, ${3:date})
|
||||||
|
|
@ -33,10 +33,24 @@ snippet createproc
|
||||||
-- Add the parameters for the stored procedure here
|
-- Add the parameters for the stored procedure here
|
||||||
AS
|
AS
|
||||||
BEGIN
|
BEGIN
|
||||||
-- SET NOCOUNT ON added to prevent extra result sets from
|
-- SET NOCOUNT ON added to prevent extra result sets from interfering with SELECT statements.
|
||||||
-- interfering with SELECT statements.
|
|
||||||
SET NOCOUNT ON;
|
SET NOCOUNT ON;
|
||||||
|
|
||||||
-- Insert statements for procedure here
|
END
|
||||||
|
GO
|
||||||
|
# Create Scalar Function
|
||||||
|
snippet createfn
|
||||||
|
-- =============================================
|
||||||
|
-- Author: ${1:Author}
|
||||||
|
-- Create date: ${2:Date}
|
||||||
|
-- Description: ${3:Description}
|
||||||
|
-- =============================================
|
||||||
|
CREATE FUNCTION ${4:Scalar_Function_Name}
|
||||||
|
-- Add the parameters for the function here
|
||||||
|
RETURNS ${5:Function_Data_Type}
|
||||||
|
AS
|
||||||
|
BEGIN
|
||||||
|
DECLARE @Result ${5:Function_Data_Type}
|
||||||
|
|
||||||
END
|
END
|
||||||
GO
|
GO
|
||||||
Loading…
Add table
Add a link
Reference in a new issue