-
Notifications
You must be signed in to change notification settings - Fork 0
/
CreateDataBase.bat
69 lines (49 loc) · 1.43 KB
/
CreateDataBase.bat
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
@echo off
cls
SET SQLCMD="C:\Program Files\Microsoft SQL Server\110\Tools\Binn\SQLCMD.EXE"
set /p SERVER=Please enter the sqlServerName:
SET UName="PrisonAdmin"
SET Pwd="ABCD"
SET ZeroPath="Prison.App.Data"
SET FirstScriptsPath="..\Database\"
SET Tables="Tables\"
SET StoredProcedures=..\StoredProcedures\
SET Inserts=..\Inserts\
SET Types=..\Types\
SET LastScriptsPath=..\Constraints\
SET DB="Prison"
SET OUTPUT="%~dp0\OutputLog.txt"
set targetFile=app.config
ECHO %date% %time% > %OUTPUT%
CD %ZeroPath%
@echo ^<connectionStrings^> >>%targetFile%
@echo ^<add name="PrisonConnection" connectionString="Data Source=%SERVER%;Initial Catalog=Prison;Persist Security Info=True;User ID=PrisonAdmin;Password=ABCD"/^> >>%targetFile%
@echo ^</connectionStrings^> >>%targetFile%
@echo ^</configuration^> >>%targetFile%
CD %FirstScriptsPath%
for %%f in (*.sql) do (
SQLCMD -S %SERVER% -i %%~f >> %OUTPUT%
)
CD %Tables%
for %%f in (*.sql) do (
SQLCMD -S %SERVER% -U %UName% -P %Pwd% -i %%~f >> %OUTPUT%
)
CD %Types%
for %%f in (*.sql) do (
SQLCMD -S %SERVER% -U %UName% -P %Pwd% -i %%~f >> %OUTPUT%
)
CD %StoredProcedures%
for %%f in (*.sql) do (
SQLCMD -S %SERVER% -U %UName% -P %Pwd% -i %%~f >> %OUTPUT%
)
CD %Inserts%
for %%f in (*.sql) do (
SQLCMD -S %SERVER% -U %UName% -P %Pwd% -i %%~f >> %OUTPUT%
)
CD %LastScriptsPath%
for %%f in (*.sql) do (
SQLCMD -S %SERVER% -U %UName% -P %Pwd% -i %%~f >> %OUTPUT%
)
@echo DataBase is created!
@echo off
pause