Chapter 7th Example

Source: Internet
Author: User


--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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.