-
-
Notifications
You must be signed in to change notification settings - Fork 19
/
Funcionario.sql
102 lines (79 loc) · 2.55 KB
/
Funcionario.sql
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
/*
Deployment script for C:\USERS\GLAUCIA\DOWNLOADS\LABS\CRUD-MVC5-EF-ANGULARJS\EMP_XPTO\CRUD_MVC5_ANGULARJS\APP_DATA\FUNCIONARIOS.MDF
This code was generated by a tool.
Changes to this file may cause incorrect behavior and will be lost if
the code is regenerated.
*/
GO
SET ANSI_NULLS, ANSI_PADDING, ANSI_WARNINGS, ARITHABORT, CONCAT_NULL_YIELDS_NULL, QUOTED_IDENTIFIER ON;
SET NUMERIC_ROUNDABORT OFF;
GO
:setvar DatabaseName "C:\USERS\GLAUCIA\DOWNLOADS\LABS\CRUD-MVC5-EF-ANGULARJS\EMP_XPTO\CRUD_MVC5_ANGULARJS\APP_DATA\FUNCIONARIOS.MDF"
:setvar DefaultFilePrefix "C_\USERS\GLAUCIA\DOWNLOADS\LABS\CRUD-MVC5-EF-ANGULARJS\EMP_XPTO\CRUD_MVC5_ANGULARJS\APP_DATA\FUNCIONARIOS.MDF_"
:setvar DefaultDataPath "C:\Users\Glaucia\AppData\Local\Microsoft\Microsoft SQL Server Local DB\Instances\MSSQLLocalDB\"
:setvar DefaultLogPath "C:\Users\Glaucia\AppData\Local\Microsoft\Microsoft SQL Server Local DB\Instances\MSSQLLocalDB\"
GO
:on error exit
GO
/*
Detect SQLCMD mode and disable script execution if SQLCMD mode is not supported.
To re-enable the script after enabling SQLCMD mode, execute the following:
SET NOEXEC OFF;
*/
:setvar __IsSqlCmdEnabled "True"
GO
IF N'$(__IsSqlCmdEnabled)' NOT LIKE N'True'
BEGIN
PRINT N'SQLCMD mode must be enabled to successfully execute this script.';
SET NOEXEC ON;
END
GO
USE [$(DatabaseName)];
GO
PRINT N'Rename refactoring operation with key is skipped, element [dbo].[Table].[Id] (SqlSimpleColumn) will not be renamed to FuncionarioId';
GO
IF (SELECT OBJECT_ID('tempdb..#tmpErrors')) IS NOT NULL DROP TABLE #tmpErrors
GO
CREATE TABLE #tmpErrors (Error int)
GO
SET XACT_ABORT ON
GO
SET TRANSACTION ISOLATION LEVEL READ COMMITTED
GO
BEGIN TRANSACTION
GO
PRINT N'Creating [dbo].[Funcionario]...';
GO
CREATE TABLE [dbo].[Funcionario] (
[FuncionarioId] INT IDENTITY (1, 1) NOT NULL,
[Nome] NVARCHAR (100) NULL,
[Departamento] NVARCHAR (50) NULL,
[Cargo] NVARCHAR (50) NULL,
[Email] NVARCHAR (50) NULL,
PRIMARY KEY CLUSTERED ([FuncionarioId] ASC)
);
GO
IF @@ERROR <> 0
AND @@TRANCOUNT > 0
BEGIN
ROLLBACK;
END
IF @@TRANCOUNT = 0
BEGIN
INSERT INTO #tmpErrors (Error)
VALUES (1);
BEGIN TRANSACTION;
END
GO
IF EXISTS (SELECT * FROM #tmpErrors) ROLLBACK TRANSACTION
GO
IF @@TRANCOUNT>0 BEGIN
PRINT N'The transacted portion of the database update succeeded.'
COMMIT TRANSACTION
END
ELSE PRINT N'The transacted portion of the database update failed.'
GO
DROP TABLE #tmpErrors
GO
PRINT N'Update complete.';
GO