SQL Server manages commonly used SQL and T-SQL

Source: Internet
Author: User
Tags microsoft sql server

1. View the version of the database

SELECT @ @version

Several common SQL Server patched version numbers:

8.00.194 Microsoft SQL Server 2000

8.00.384 Microsoft SQL Server SP1

8.00.532 Microsoft SQL Server SP2

8.00.760 Microsoft SQL Server SP3

8.00.818 Microsoft SQL Server SP3 w/cumulative Patch ms03-031

8.00.2039 Microsoft SQL Server SP4

2. View the machine operating system parameters of the database

EXEC master.. xp_msver

3. View Database Startup Parameters

sp_configure

4. View Database Startup time

Select CONVERT (varchar, login_time,120) from master. sysprocesses where spid=1

To view the database server name and instance name

print ' Server Name ... ...: ' + CONVERT (varchar (), @ @SERVERNAME), ".

print ' Instance ....: ' + CONVERT (varchar), @ @SERVICENAME. @)., d..

5. View all database names and sizes

sp_helpdb

To rename SQL for a database

Sp_renamedb ' Old_dbname ', ' new_dbname '

6. View all database user login information

Sp_helplogins

View the role information that all database users belong to

Sp_helpsrvrolemember

Fix_orphan_user scripts or Loneuser procedures that can be used when repairing orphaned users when migrating servers

Change the user owner of a data object

sp_changeobjectowner [@objectname =] ' object ', [@newowner =] ' owner '

Note: Changing any part of an object name can corrupt scripts and stored procedures.

To back up the database user login information on a single server, you can use Add_login_to_aserver script

View Object-level user permissions under a database

Sp_helprotect

Related Article

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.