--use of common system stored procedures
EXEC sp_databases--Lists the databases in the current system
EXEC sp_renamedb ' MyBank ', ' Bank '--Change the name of the database (single user access)
Use MySchool
Go
EXEC sp_tables--List of Queryable objects in the current database
EXEC sp_columns student--View the information in the columns in the Student table
EXEC sp_help student--View all the information in the student table
EXEC sp_helpconstraint student--View constraints in the student table
EXEC sp_helptext view_student_result--View statement file
EXEC Sp_stored_procedures--Returns a list of stored procedures in the current database
--Example 2
--purpose:xp_cmdshell use of extended stored procedures
Use master
Go
/* If xp_cmdshell is turned off as part of the server security configuration, use the following statement to enable */
EXEC sp_configure ' show advanced options ', 1---display high-level configuration information
Go
Reconfigure--RECONFIGURE
Go
EXEC sp_configure ' xp_cmdshell ', 1--Open xp_cmdshell selection
Go
Reconfigure--RECONFIGURE
Go
/*--CREATE database BANKDB, required to be saved in D:\bank directory--*/
exec xp_cmdshell ' mkdir E:\bank ', no_output--Create folder D:\bankDB
--Create a database bankdb
If exists (select *from sysdatabases where name= ' bankdb ')
DROP Database Bankdb
Go
Create DATABASE Bankdb
On
(
Name= ' Bankdb_data ',
Filename= ' E:\bank\bankDB_data.mdf ',
SIZE=3MB,
filegowth=15%
)
Log on
(
Name= ' Bankdb_log ',
Filename= ' E;\bank\bankdb-log.ldf ',
SIZE=3MB,
filegrowth=15%
)
Go
exec xp_cmdshell ' dir E:\bank\ '--View file
Select Top 2 * from Student where Studentno not in (select top 2 studentno from Student Order by Studentno) Order by Studen TNo
Select *from (select *,row_number () over (order by Studentno) as myID from student) as temp where myID between 3 and 4
Chapter 7th Example