segunda-feira, 23 de novembro de 2009

Execução de comandos no shell do windows e definição do Database no Sql Server

-------------------------------------------------------------
Exec SP_Configure

Exec SP_Configure 'show advanced options',1
RECONFIGURE

Exec SP_Configure 'xp_cmdshell',1
RECONFIGURE

Exec xp_cmdshell 'MD C:\Bancos'
-------------------------------------------------------------
CREATE DATABASE Escola
ON
(
name = 'Escola_Dados' ,
filename = 'C:\Bancos\Escola_Dados.mdf',
size = 10MB,
maxsize = 100MB,
filegrowth = 10MB
)
-------------------------------------------------------------
Exec xp_cmdshell 'Dir C:\Bancos\*.*'
-------------------------------------------------------------
Use master

DROP DATABASE Escola

Exec xp_cmdshell 'Dir C:\Bancos\*.*'
-------------------------------------------------------------
CREATE DATABASE Escola
ON
(
name = 'Escola_Dados' ,
filename = 'C:\Bancos\Escola_Dados.mdf',
size = 10MB,
maxsize = 100MB,
filegrowth = 10MB
)
LOG ON
(
name = 'Escola_Log' ,
filename = 'C:\Bancos\Escola_Log.ldf',
size = 1MB,
maxsize = 10MB,
filegrowth = 1MB
)

Exec xp_cmdshell 'Dir C:\Bancos\*.*'
-------------------------------------------------------------






Nenhum comentário:

Postar um comentário