TOP

MS Sql How to Use SP CONFIGURE

How to Use SP CONFIGURE

See Also: Architecture & Configuration - Server-Level Configuration

Contents

[hide]

What is SP_Configure?

SP_Configure is a system stored procedure that you can modify most SQL Server configuration options with. In fact there are more options to configure here than exists through the GUI based tools.

While the GUI based configuration tools (SQL Server Management Studio’s options, SQL Server Configuration Manager, etc.) provide an easy interface, using SP_Configure is preferred by many DBAs. It allows more control and can give a DBA the opportunity to script out a change to apply to multiple environments.

How Do I Use Sp_Configure?

That depends on what you are trying to do. You can use it to view or modify server configuration options (Though there is a better way to view those options in 2005/2008, described below)

 

View Settings

Want to take a look at your SQL Settings? Open a query window and just type and run sp_configure; you’ll likely get a partial list of settings. To see them all you have to enable an option called ‘Show Advanced Options’, described below.

 

Change Settings

Be careful.. Changing settings affects your instance, a lack of understanding of a result could dramatically affect your instance, performance, availability, etc. Look up a setting in books online and understand it first! This post is not about the settings, it is about the tool used to change the settings. Books Online is a great, free, resource when you have SQL Server installed, you can also get Books Online on the web (2005,2008). No excuses here about making a setting change without understanding it and testing it.
Alright, now that the disclaimer is done… You use sp_configure to change settings as well as view. You simply type sp_configure ‘setting name’ (*) followed by the value. Execute that and you either have to restart the instance or execute the statement “RECONFIGURE” depending on if the setting is dynamic or not (explained below)

For example – if you wanted to show advanced options you would type:

SP_CONFIGURE 'show advanced options', 1
GO
RECONFIGURE
GO;

Then when you run sp_configure again, you will see all of the available options.

 

A Shortcut Tip

You don’t have to type all of the value when using SP_Configure. You can type an unambiguous portion of a configuration option and the server will understand what you mean. For example SP_Configure ‘Degree’ would display the configuration settings for “Max Degree of Parallelism.”

 

Output Columns of SP_Configure
  • name - The name of the value to be changed, again you can look up the definition for these values in books online.
  • minimum - The minimum value setting that is allowed
  • maximum - Yea, the maximum value that is allowed
  • config_value - What value is currently configured?
  • run_value - What value is currently running? Difference between this and above? You make a change but don’t restart or run reconfigure: The config_value and run_value will be different until that reconfigure (if dynamic) or restart.

SYS.Configurations

The is a view only twin of sp_configure that comes with SQL Server 2005 and 2008. You can select from this catalog view to see configuration options. No changing of settings necessary to see all options here since you can’t change them, it is a way to view your options and you can filter with a where clause.

This catalog view has several columns, the ones that are an exact match to a column in sp_configure will be ignored but the rest:

  • configuration_id - Just an internal ID of the configuration setting. Good for trivia? I don’t use it for anything…
  • value - same as config_value above
  • value_in_use - (see that is why I said Seriously? A blog post on sp_configure?) obviously the twin of run_value above.
  • description - Very nice, a brief description that is a little less cryptic then the name column here or in sp_configure. I was going to say it might save you a trip to books online but if you didn’t know what it meant before reading a couple more words, you should still visit books online and understand the setting.
  • is_dynamic - This very helpful tells you if a value is dynamic or not. A dynamic value is one that simply needs to be changed with a “RECONFIGURE”. If it is not dynamic, it requires a restart of the SQL Server Service. The next time your manager asks you, “Does changing the max memory in SQL Server require a reboot?” you can look here and see the dynamic flag of 1 meaning, “no boss, we can change it on the fly.”
  • is_advanced - Like the above, ever wonder if you have to change the show advanced option to display a value? Well you can find out here. It’s a flag, 1 is yes, 0 is no, like the is_dynamic flag.

Author Credits

Mike Walsh

This wiki article was adapted from a blog post by Mike Walsh.

Read More
TOP

MS SQL Server and CPU usage

http://www.eraofdata.com/blog/how-many-cpus-can-sql-server-use/

 

SQL Server and CPU usage

How many CPUs can SQL Server supports should be a simple question, you might think. But judging by how often this question is asked on the SQL Server forums its clear that there is a lot of confusion about exactly how many CPUs a particular edition of SQL Server can use.

The problem is due mainly to incorrect assumptions about Microsoft’s licencing policy, combined with the prevalence of multi-core CPUs. This has led to some incorrect responses to postings about CPU licencing on the SQL Server forums, so I’ve decided it’s worth blogging about to try and clarify the matter.

This post covers SQL Server 2005 and SQL Server 2008 editions.

Microsoft’s multicore licencing policy is based on the number of sockets on the motherboard, notthe number of cores (EDIT 20111118: this is apparently going to change in SQL Server 2012 and will fall in line with the rest of the industry where a formula will be applied based on the number of cores). Therefore, for licencing purposes, a dual-core CPU equates to 1 CPU, not 2. A quad-core CPU equates to 1 CPU, not 4 etc. etc.

What this means is that your free SQL Express edition can use all 4 cores in your quad core CPU and not just one core. You can verify this by interrogating the sys.dm_os_sys_info SQL Server dynamic management view (DMV), particularly. The following query lists how many CPUs a particular instance of SQL Server can see:

select cpu_count from sys.dm_os_sys_info

The sys.dm_os_sys_info DMV returns a whole host of other useful information that used to be very difficult to obtain without using xp_cmdshell or WMI, so it’s well worth exploring further. In fact, most of the DMVs have invaluable information if you know what you’re looking for, but that’s a subject area far too large for a blog; just peruse Books Online as that gives a complete listing and a good rundown of what each DMV offers.
Just remember that, although SQL Server Express will be able to see multiple CPUs and use them to improve concurrency, SQL Server Express edition is prevented from taking advantage of this to parallelise individual queries, which basically means that an individual query will not be executed across multiple CPUs.

Confirming how many CPUs SQL Server is using

Back to counting CPUs. To find out how many CPUs a particular instance is actually using, run the following query which is based on the sys.dm_os_schedulers DMV:

select scheduler_id,cpu_id, status, is_online from sys.dm_os_schedulers where status='VISIBLE ONLINE'

This will return how many CPUs SQL Server is using. Ordinarily, this will always equate to the number of CPUs on the system. However, if CPU affinity is being used to assign specific CPUs to SQL Server, this query will show how many CPUs SQL Server is actively using.

Run the query without the where clause to see how many CPUs are offline and not being used (their status will be VISIBLE OFFLINE). The additional rows returned will show up internally used schedulers such as the scheduler retained for the Dedicated Admin Connection, or DAC.

If this query does not list the number of CPUs you are expecting, and you’re definitely not using CPU affinity, check the edition of SQL Server that you are using against the table below.

Note: To confirm that CPU affinity is indeed being used, the cpu_id column will always be less than 255.

CPUs supported by the various SQL Server Editions

A summary of how many CPUs the different editions of SQL Server support is summarised in the table below:

SQL Server version Express Workgroup Web Standard Enterprise
SQL Server 2005 1 2 n/a 4 Unlimited1
SQL Server 2008 1 2 4 4 Unlimited1
1Subject to OS limits 

 

Read More
TOP

MS SQL Server memory configuration

http://www.eraofdata.com/blog/sql-server-memory-configuration/

SQL Server memory configuration

One of the things that I frequently come across when reviewing SQL Server installations is just how many of them have not been set up with appropriate memory configuration settings, or, as in many cases, not set up in the way the administrators of the system had assumed they were; usually the dbas thought the system was set up to use all e.g. 8GB of RAM, but no changes had been made to the OS or SQL Server configuration, so their (32-bit) SQL Server would only be accessing 2 GB, and reporting that it was using 1.6 GB.

The problem is due in part to the fact that on 32-bit systems configuration changes usually have to be made both in SQL Server and at the OS level, and in part to the sprawl of documentation available on configuring SQL Server’s memory settings, as opposed to a single jumping off point which runs through all the settings and considerations that need to be made.
Add to that the black art of establishing exactly how much memory SQL Server is using (most of the obvious options will only show how much memory the buffer pool is using) and it’s easy to see why it’s such a problem area.

In this post I’ll attempt to clear some of the smog and provide what I hope will be one document which answers most of the questions that arise about configuring SQL Server’s memory usage.
This discussion will cover configuring memory for SQL Server 2000, SQL Server 2005 and SQL Server 2008 (with the exception of the Resource Governor). This blog assumes an edition of SQL Server that is not internally limited in its memory usage.

32-bit or 64-bit?

There’s a big difference between the memory configuration settings between 64-bit SQL Server and 32-bit SQL Server, so it’s not possible to start a discussion about SQL Server’s memory management without clarifying whether we are dealing with 32-bit versions or 64-bit versions of the product, as this is key to how much memory SQL Server can address, and (almost as importantly) how it addresses that memory.

Configuring 32-bit SQL Server

Until fairly recently 32-bit software was ubiquitous. The server Windows operating systems were 32-bit, your desktop, usually Windows XP was 32-bit. Therefore, I’ll be focusing a fair bit on 32-bit SQL Server as this is what requires the most configuration, and also where most of the confusion lies.

So, here goes.

The amount of memory a 32-bit process can access is 2^32 or 4294967296 bytes, or 4 GB.
On a 32-bit Windows OS this 4 GB of memory is not all addressable by a single process. Instead, it’s partitioned by the OS into two address spaces. 2 GB is kept by the OS (commonly referred to as the kernel) and the remaining 2 GB is the user mode address space, or the area each application (process) will have access to. Whilst each user mode process gets 2 GB as its addressable memory range, the kernel mode area is shared between all processes. SQL Server runs in the user mode address space and is bound by default to the 2 GB of memory limit on a 32-bit OS.
This directly addressable memory will hereon be referred to by what it is more commonly known as, the virtual address space or VAS.

SQL Server’s default out-of-the-box memory limit is deliberately set to a very high value of 2147483647 , which basically means all available memory, but as you should now know, there’s no way it can actually use anywhere near that much memory, particularly on a 32-bit platform.

64-bit operating systems have a far far bigger address space open to them; 8 TB to be exact. Before you run off to your calculator to evaluate 2^64, the answer won’t be 8TB, but 8TB is what each user mode application gets due to current hardware and OS limitations. The kernel also gets 8TB and this kernel address space is shared by all processes, just as in 32-bit Windows.

Having said all that, I should point out that no current MS Windows OS can address more than 2 TB.

What this means for 64-bit SQL Server is that out of the box, it can address all the memory on a server without any special configuration changes either within SQL Server or at the OS level. The only thing you need to look at is a cap on its memory usage; capping memory usage is covered in the ‘max server memory’ and ‘min server memory’ section which is further down.

To /3GB or not to /3GB

So, as 32-bit applications are natively restricted to a 2 GB VAS, OS configuration tweaks are required to allow access to more than 2 GB, and these are covered next.

The first modification is one that, rather ironically, should be used as a last resort. Ideally, it should be used on the advice of Microsoft Support (PSS).
I’m choosing to get it out of the way now because the /3GB setting is probably the most well known and most misused.
/3GB allows a 32-bit process to increase its VAS to 3 GB by taking away 1 GB of address space from the kernel, and this is why it’s a last resort; there’s no such thing as a free lunch as the removal of 1 GB of addressable memory from the OS can introduce instability. More on that shortly.

To allow a 32-bit process to gain a 3 GB VAS you have to add the /3GB switch to the Windows boot.ini file.

As I stated, this can introduce system instability by starving the OS of System Page Table Entries (PTEs). A discussion about PTEs is out of the scope of this blog, but its effects can be dramatic and cause blue-screens. The good news is that this mainly affected Windows 2000 so you should be fine if you’re on a later Windows version.

If you’re still looking after a legacy system, there is some scope for manoeuvre here, by adding the/USERVA switch to the boot.ini it is possible to reduce the VAS increase from a straight 3 GB to a lower user-defined amount which will give the OS room to breathe, and thus resolve any instability issues.

The main reason you will be advised by PSS to use /3GB is if you are suffering VAS starvation issues, such as a bloated procedure cache as it can only reside in VAS memory (also see the next section on MemToLeave) because 32-bit version of SQL Server only allow database pages to reside in the part of the SQL Server memory cache (called the buffer pool) that is utilising awe enabled memory.

MemToLeave

(EDIT:[20110630] The correct terminology for this is Virtual Address Space Reservation.)
Because of the inherent address space limitations of a 32-bit process, a certain amount of memory has to be set aside by SQL Server on startup that SQL Server uses for overheads. This memory is set aside in case it all gets used by the buffer pool.

COM objects, extended stored procs, third party backup solutions, some anti-virus apps, memory allocations exceeding 8K and the memory allocated to the threads SQL Server creates to service e.g. user connections come from a section of memory within the VAS but outside the buffer pool which is typically referred to as the MemToLeave area. This is 384 MB by default on an e.g. 2-proc 32-bit SQL. If you want to know more about how it is calculated, check Jonathan Kehayias’s postcovering this.

0.5 MB is the default thread stack size for a thread on 32-bit Windows. 64-bit Windows has a default stack size of 2 MB or 4 MB depending on which 64-bit flavour of Windows you are running (AMD x64 or IA64).
SQL Server 2005 and beyond uses a formula to calculate the max worker threads setting which affects the size of the MemToLeave area.
There is a SQL Server startup parameter (-g) which can be used to increase the MemToLeave area, but again, only do this if advised by PSS (it’s ignored on 64-bit as MemToLeave or VAS reservation won’t be an issue on that architecture) as this will reduce the maximum amount of memory the buffer pool can therefore use.

4 GB of RAM and beyond

So, we know 32-bit SQL Server can use 2 GB out of the box, and up to 3 GB (with an OS tweak that is best avoided, if at all possible).
However, 32-bit SQL Server can benefit from much more memory than 3 GB with the help of OS and SQL Server configuration modifications which will be covered next.

/PAE

To address more than 4 GB of RAM on 32-bit Windows, the OS needs to have the /PAE switch added to the boot.ini file, although if your system supports hot-swappable memory you won’t need to add this as Windows should automatically be able to see the additional memory. If you’re not sure, take a look at how much memory the OS can see via System properties; if you have more than 4 GB installed and the OS is only showing 4 GB, review your boot.ini settings. I’m not mentioning specific Windows versions because the /PAE switch applies to all current 32-bit versions of Windows.
(EDIT:[20110630] For Windows Server 2008 you have to run ‘BCDEDIT /SET PAE FORCEENABLE’ from a CMD prompt running under administrator privileges).

Both /PAE and /3GB

Some systems have both /3GB and /PAE enabled.
This is fine as long as the system does not have more than 16 GB of RAM. Add any more memory and Windows will not recognise it because of the overhead required to manage the additional memory.

Clusters

No special configuration settings regarding memory settings are required for a cluster, but I thought I better mention clusters specifically because you won’t believe how many installations there are out there where there are different settings on different nodes within the same cluster.
So, make sure any OS setting changes like /3GB or /PAE are consistently applied across all nodes.

Enable AWE

After configuring the OS, you’ll need to configure SQL Server by enabling AWE (Address Windowing Extensions). AWE is in essence a technique for ‘paging’ in sections of memory beyond the default addressable range.
AWE can be enabled in SQL Server using Query Analyzer/SQL Server Management Studio (SSMS) via the following statements:

sp_configure 'show advanced options', 1
RECONFIGURE
GO
sp_configure 'awe enabled', 1
RECONFIGURE
GO

AWE enablement is not a dynamic option and will require a SQL Server restart, so before you do that make sure the SQL Server service account has the ‘Lock Pages in Memory’ privilege assigned to it.
Once AWE has been enabled within SQL Server and the ‘Lock Pages in Memory’ privilege has been assigned you should be good to go after a restart.

‘max server memory’ and ‘min server memory’

The more memory you give SQL Server, the greater the need to set an upper limit on how much it uses. When you start SQL Server it’ll ramp up its memory usage until it has used up all the memory it can access, which will either be an internal OS limit or a SQL Server configured limit.
A 32-bit SQL Server instance will therefore grab up to 2 GB if the workload demands it and it is on default settings.
An awe enabled SQL Server instance will go on using up all the memory on the system if the workload is there and an upper limit on its memory usage is not set.

Setting a limit has the double-benefit of not starving the OS of resources and avoiding ‘Out of memory’ errors which can occur on SQL Server systems that may have a lot of memory. The latter (rather contradictory) situation can arise because SQL Server will try and allocate more memory when it is already at the system limit (if no upper limit has been set via the ‘max server memory’ setting) instead of freeing up memory it is already using.

Configuring memory for multiple instances

A third reason to set an upper limit is if you have more than one SQL Server instance installed on a single host, as this will stop the instances competing for memory.
Allocate a high enough ‘max server memory’ limit to each instance to allow it to do its job without running into memory starvation issues, whilst reserving the bulk of the memory for higher priority instances (if any) and the OS.
This is where benchmarking comes in handy.

To set a max server memory limit of 12 GB via Query Analyzer/SSMS:

sp_configure 'max server memory', 12288
RECONFIGURE
GO

SQL Server ramps up its memory usage because by default it is set to use no memory on startup. This is controlled by the ‘min server memory’ setting. Specifying this to a higher value has the benefit of reserving a set amount of memory for SQL Server from the off which can provide a slight performance benefit, especially on busy systems. It’s actually not uncommon to see ‘min server memory’ and ‘max server memory’ set to the same value, to reserve all of SQL Server’s memory straight away. The downside is SQL Server will take slightly longer to start up than if ‘min server memory’ was set to a low value.

SQL does not really release memory

This will probably get me into a bit of trouble, as there are KBs that clearly state that SQL Server releases memory when the OS is under pressure.
True, but only when it’s under a lot of pressure (although this is getting better with each version of SQL Server), and by then it’s often too late as the system is usually in such a degraded state by that stage that a restart is necessary.
That’s why it’s vital to set an upper limit on its memory usage via the ‘max server memory’ setting.
(Edit [20110627): Speaking from experience, this problem manifested itself most noticeably on SQL Server 2000 and earlier but the problem seems to have disappeared from SQL 2005 onwards. Let me know if you disagree (and send me the evidence!)).

Memory corruption

Slightly off-topic, but this is an appropriate place to bring this up.
Certain builds of Windows 2000 and Windows Server 2003 contained a potentially serious memory corruption problem which affected SQL Server more than other applications, mainly because there are few applications that run on Windows that can utilise the amount of memory SQL Server does.
It’s difficult to overstate the problems this can cause, so make sure you’re on the appropriate Windows Service Packs if you’re running SQL Server on a PAE enabled system.
Another issue that arose in SQL Server 2000 SP4 was a bug that meant SQL Server only saw half the memory on awe enabled systems, although it was identified quickly and the hotfix for this was placed alongside the SP4 download.

32-bit SQL Server on 64-bit Windows

If you 32-bit SQL Server on 64-bit Windows the SQL Server process can access the entire 4 GB VAS.

Checking SQL Server’s memory usage

This is another area where there is lot of confusion, so below is a run-through of the most common methods for confirming SQL Server’s memory usage.

Ignore Task Manager

If you have an awe enabled SQL Server instance, do not rely on Task Manager to display memory usage as it does not show the AWE memory a process is using, so the memory usage figure it presents for the SQL Server process (sqlservr.exe) will be incorrect.

DBCC MEMORYSTATUS

Running the above command outputs the memory usage of SQL Server including how that memory is allocated, so unless you need to know how and where that memory is being used, the output it generates can be a bit bewildering. The important bits of this output pertaining to SQL Server’s total memory usage are as follows:

Buffer Counts                  Buffers
------------------------------ --------------------
Committed                      3872
Target                         65536
Hashed                         2485
Stolen Potential               60972
External Reservation           0
Min Free                       64
Visible                        65536
Available Paging File          702099

The key figures in the above output are committed, target and hashed.
Committed is the amount of memory in use by the buffer pool and includes AWE pages.
Target is how big SQL Server wants the buffer to grow, so you can infer from this whether SQL Server wants more memory or is releasing memory.
There’s an excellent KB on interpreting all the output INF: Using DBCC MEMORYSTATUS to Monitor SQL Server Memory Usage for SQL Server 2000 and How to use the DBCC MEMORYSTATUS command to monitor memory usage on SQL Server 2005.
Edit (05/02/09): Remember the buffer count numbers refer to pages of memory which are 8K in SQL Server

System Monitor (perfmon)

Perfect way to get a quick reference on exactly how much memory SQL Server is using at that moment. Start System Monitor and add the SQL Server: Memory Manager: Total Server Memory (KB) counter.

Replace “SQL Server” with MSSQL$ and the name of the named instance if it’s not a default instance, e.g. MSSQL$INSTANCE1.

‘Total’ memory usage

When trying to establish exactly how much memory SQL Server is using it’s not just the buffer pool memory you have look at, but the MemToLeave area as well. The key point to bear in mind here is that it’s not only SQL Server that can make allocations from this latter area of memory but third party processes as well, which can make it impossible to precisely account for SQL Server’s absolute memory usage, contrary to some myths out there about calculating SQL Server’s memory usage via e.g. DBCC MEMORYSTATUS, as such methods can only account for SQL Server’s own memory allocations and not allocations by foreign processes.

Edit [20110627]: Soft NUMA section removed.

64-bit

I mentioned at the start of this post that all you have to worry about for 64-bit SQL Server is setting a max memory limit as SQL Server can access all the memory current Windows operating systems can support, and 8 TB in total. That’s mostly true, with the exception of a certain privilege that the SQL Server service account needs, and that’s the ‘Lock Pages in Memory’ privilege.
This privilege is vital as it prevents the OS from paging out SQL Server memory to the swap file.
With the introduction of SQL Server 2005, this right was restricted on 64-bit Windows to only take effect on Enterprise Editions of SQL Server, so if you’re wondering why your huge new multi-gigabyte multi-core 64-bit system is paging like crazy, this might be why. [Edit: This has finally been reversed for both SQL Server 2005 and SQL Server 2008 Standard Editions:http://blogs.msdn.com/psssql/archive/2009/04/24/sql-server-locked-pages-and-standard-sku.aspx
Whilst we’re on the subject of paging on 64-bit SQL Server systems, take a look at the following KB:
How to reduce paging of buffer pool memory in the 64-bit version of SQL Server 2005 which covers issues a number of issues that cause SQL Server’s (Standard or Enterprise editions) memory to be paged out.

In summary…

The table below describes how much memory SQL Server can use, and assumes an edition of SQL Server that has no internal limitations as to how much memory it can use, e.g. Express and Workgroup editions are limited to 1 GB and 3GB respectively.

SQL Server type Installed physical memory
Up to 4GB More than 4GB (/PAE enabled 1)
32-bit SQL Server Default memory usage With /3GB 2 All available RAM3
2 GB 3 GB
64-bit SQL Server All available RAM 3
1 Not all 32-bit systems now need to have /PAE explicitly set in boot.ini for the OS to see more than 4 GB of RAM 2. Assuming /USERVA switch has not been used to tune memory usage to between 2 GB and 3 GB 3. Assuming 'max server memory' is left on defaults, otherwise SQL Server will use no more memory than that stipulated by the 'max server memory'setting.

When I started this post I wanted to keep it as short and succinct as possible, but there’s a lot more to configuring SQL Server’s memory usage than simply setting a ‘max server memory’ limit. Configuring SQL Server’s memory settings can be quite a complex undertaking, especially in a 32-bit environment. It’s not easy to cover all the pertinent points without branching off and describing the different areas of its memory architecture, although I’ve tried to provide the relevant information without going into too much detail.
Hopefully, this blog has clarified how to configure SQL Server’s memory usage and provided enough information to answer most memory configuration related questions, although, as you might have guessed, there’s no black-and-white way of precisely determining SQL Server’s memory usage as there are so many external processes that can make allocations from within SQL Server’s address space…

Thanks also to Jonathan Keheyias for additional information and comments on this post. Please readhis post on this topic if you want to delve a bit deeper.

Useful links

How It Works: DBCC MemoryStatus Locked Pages Allocated and SinglePageAllocator Values

INF: Using DBCC MEMORYSTATUS to Monitor SQL Server Memory Usage

MemToLeave and 64-bit SQL Server

Tags: ,

Read More
TOP

MS SQL Tricks & Tips

http://ss64.com/sql/
An A-Z Index of the SQL Server 2005 database
Aggregate - CREATE AGGREGATE
          - DROP AGGREGATE
Application Role - CREATE APPLICATION ROLE
                 - ALTER APPLICATION ROLE
                 - DROP APPLICATION ROLE
Assembly - CREATE ASSEMBLY
         - ALTER ASSEMBLY
         - DROP ASSEMBLY
ALTER AUTHORIZATION

BACKUP
BACKUP CERTIFICATE
BEGIN [DIALOG [CONVERSATION]]

Certificate - ALTER CERTIFICATE
            - CREATE CERTIFICATE
            - DROP CERTIFICATE
CHECKPOINT
COMMIT
Contract - CREATE CONTRACT
         - DROP CONTRACT
Credential - CREATE CREDENTIAL
           - ALTER CREDENTIAL
           - DROP CREDENTIAL

Database - CREATE DATABASE
         - ALTER DATABASE
         - DROP DATABASE
DBCC CHECKALLOC   - Check consistency of disk allocation.
DBCC CHECKCATALOG - Check catalog consistency
DBCC CHECKCONSTRAINTS - Check integrity of table constraints.
DBCC CHECKDB    - Check allocation, and integrity of all objects.
DBCC CHECKFILEGROUP - Check all tables and indexed views in a filegroup.
DBCC CHECKIDENT - Check identity value for a table.
DBCC CHECKTABLE - Check integrity of a table or indexed view.
DBCC CLEANTABLE - Reclaim space from dropped variable-length columns.
DBCC dllname    - Unload a DLL from memory.
DBCC DROPCLEANBUFFERS - Remove all clean buffers from the buffer pool.
DBCC FREE... CACHE  - Remove items from cache.
DBCC HELP        - Help for DBCC commands.
DBCC INPUTBUFFER - Display last statement sent from a client to a database instance.
DBCC OPENTRAN    - Display information about recent  transactions.
DBCC OUTPUTBUFFER - Display last statement sent from a client to a database instance.
DBCC PROCCACHE   - Display information about the procedure cache
DBCC SHOW_STATISTICS - Display the current distribution statistics
DBCC SHRINKDATABASE - Shrink the size of the database data and log files.
DBCC SHRINKFILE  - Shrink or empty a database data or log file.  DBCC SQLPERF     - Display transaction-log space statistics. Reset wait and latch statistics.
DBCC TRACE...    - Enable or Disable trace flags
DBCC UPDATEUSAGE - Report and correct page and row count inaccuracies in catalog views
DBCC USEROPTIONS - Return the SET options currently active
DBCC deprecated commands
DECLARE
Default - CREATE DEFAULT
        - DROP DEFAULT
DELETE
DENY - DENY Object permissions
     - DENY User/Role permissions
Endpoint - CREATE ENDPOINT
         - ALTER ENDPOINT
         - DROP ENDPOINT
Event - CREATE EVENT NOTIFICATION
      - DROP EVENT NOTIFICATION
EXECUTE
EXECUTE AS

Fulltext Catalog - CREATE FULLTEXT CATALOG
                 - ALTER FULLTEXT CATALOG
                 - DROP FULLTEXT CATALOG
Fulltext Index - CREATE FULLTEXT INDEX
               - ALTER FULLTEXT INDEX
               - DROP FULLTEXT INDEX
Function - CREATE FUNCTION
         - ALTER FUNCTION
         - DROP FUNCTION

GO
GRANT - GRANT Object permissions
      - GRANT User/Role permissions

Index - CREATE INDEX
      - ALTER INDEX
      - DROP INDEX
INSERT
iSQL -U user -P password -i script.sql -o logfile.log

Key - CREATE ASYMMETRIC KEY
    - ALTER ASYMMETRIC KEY
    - DROP ASYMMETRIC KEY
    - CREATE SYMMETRIC KEY
    - OPEN SYMMETRIC KEY
    - CLOSE SYMMETRIC KEY
    - ALTER SYMMETRIC KEY
    - DROP SYMMETRIC KEY
KILL
KILL QUERY NOTIFICATION
KILL STATS JOB

Login - CREATE LOGIN
      - ALTER LOGIN
      - DROP LOGIN

Master Key - CREATE MASTER KEY
           - ALTER MASTER KEY
           - BACKUP MASTER KEY
           - DROP MASTER KEY
           - RESTORE MASTER KEY
           - ALTER SERVICE MASTER KEY
           - BACKUP SERVICE MASTER KEY
           - RESTORE SERVICE MASTER KEY
Message Type - CREATE MESSAGE TYPE
             - ALTER MESSAGE TYPE
             - DROP MESSAGE TYPE

Partition Function - CREATE PARTITION FUNCTION
                   - ALTER PARTITION FUNCTION
                   - DROP PARTITION FUNCTION
Partition Scheme - CREATE PARTITION SCHEME
                 - ALTER PARTITION SCHEME
                 - DROP PARTITION SCHEME
Procedure - CREATE PROCEDURE
          - ALTER PROCEDURE
          - DROP PROCEDURE

Queue - CREATE QUEUE
      - ALTER QUEUE
      - DROP QUEUE

Remote Service Binding - CREATE REMOTE SERVICE BINDING
                       - ALTER REMOTE SERVICE BINDING
                       - DROP REMOTE SERVICE BINDING

RESTORE - RESTORE DATABASE Complete
          RESTORE DATABASE Partial
          RESTORE DATABASE Files
          RESTORE LOGS
          RESTORE DATABASE_SNAPSHOT
          RESTORE FILELISTONLY - List database and log files
          RESTORE HEADERONLY - List backup header info
          RESTORE LABELONLY  - Media info
          RESTORE REWINDONLY - Rewind and close tape device
          RESTORE VERIFYONLY
REVERT
REVOKE - REVOKE Object permissions
       - REVOKE User/Role permissions
Role - CREATE ROLE
     - ALTER ROLE
     - DROP ROLE
ROLLBACK
Route - CREATE ROUTE
      - ALTER ROUTE
      - DROP ROUTE

Schema - CREATE SCHEMA
       - ALTER SCHEMA
       - DROP SCHEMA
SELECT
SEND
SERVERPROPERTY
Service - CREATE SERVICE
        - ALTER SERVICE
        - DROP SERVICE
SESSION_USER
SESSIONPROPERTY
SET @local_variable
SET
SHUTDOWN
Signature - ADD SIGNATURE
          - DROP SIGNATURE
Statistics - CREATE STATISTICS
           - UPDATE STATISTICS
           - DROP STATISTICS

Synonym - CREATE SYNONYM
        - DROP SYNONYM

Table - CREATE TABLE
      - ALTER TABLE
      - DROP TABLE
      - TRUNCATE TABLE
Transaction - BEGIN DISTRIBUTED TRANSACTION
            - BEGIN TRANSACTION
            - COMMIT TRANSACTION
Trigger - CREATE TRIGGER
        - ALTER TRIGGER
        - ENABLE TRIGGER
        - DISABLE TRIGGER
        - DROP TRIGGER
Type - CREATE TYPE
     - DROP TYPE

UNION
UPDATE
User - CREATE USER
     - ALTER USER
     - DROP USER
USE

View - CREATE VIEW
     - ALTER VIEW
     - DROP VIEW

XML Schema Collection - CREATE XML SCHEMA COLLECTION
                      - ALTER XML SCHEMA COLLECTION
                      - DROP XML SCHEMA COLLECTION

Related:

 Microsoft books online – T-SQL Reference: SQL 2000 | SQL 2005 | SQL 2008
SS64 Discussion forum
Links to other SQL Server websites, books etc.

 


Read More

Switch to our mobile site