forked from ajaxorg/ace
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsqlserver.snippets.js
70 lines (66 loc) · 1.95 KB
/
sqlserver.snippets.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
module.exports = `# ISNULL
snippet isnull
ISNULL(\${1:check_expression}, \${2:replacement_value})
# FORMAT
snippet format
FORMAT(\${1:value}, \${2:format})
# CAST
snippet cast
CAST(\${1:expression} AS \${2:data_type})
# CONVERT
snippet convert
CONVERT(\${1:data_type}, \${2:expression})
# DATEPART
snippet datepart
DATEPART(\${1:datepart}, \${2:date})
# DATEDIFF
snippet datediff
DATEDIFF(\${1:datepart}, \${2:startdate}, \${3:enddate})
# DATEADD
snippet dateadd
DATEADD(\${1:datepart}, \${2:number}, \${3:date})
# DATEFROMPARTS
snippet datefromparts
DATEFROMPARTS(\${1:year}, \${2:month}, \${3:day})
# OBJECT_DEFINITION
snippet objectdef
SELECT OBJECT_DEFINITION(OBJECT_ID('\${1:sys.server_permissions /*object name*/}'))
# STUFF XML
snippet stuffxml
STUFF((SELECT ', ' + \${1:ColumnName}
FROM \${2:TableName}
WHERE \${3:WhereClause}
FOR XML PATH('')), 1, 1, '') AS \${4:Alias}
\${5:/*https://msdn.microsoft.com/en-us/library/ms188043.aspx*/}
# Create Procedure
snippet createproc
-- =============================================
-- Author: \${1:Author}
-- Create date: \${2:Date}
-- Description: \${3:Description}
-- =============================================
CREATE PROCEDURE \${4:Procedure_Name}
\${5:/*Add the parameters for the stored procedure here*/}
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from interfering with SELECT statements.
SET NOCOUNT ON;
\${6:/*Add the T-SQL statements to compute the return value 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}
\${6:/*Add the T-SQL statements to compute the return value here*/}
END
GO`;