Archive

Archive for the ‘SQL Configuration’ Category

SQL Server – Displaying line numbers in Query Editor – SSMS

January 20, 2014 Leave a comment

You can enable line numbers to be displayed in SSMS Query Editor. This is extremely useful when working on a large module.

To enable line numbers in Query Editor windows, follow below steps:

Step1: Go to Tools > Options

image

Step2: In the Options dialog box navigate to Text Editor > Transact-SQL > General

image

Step 3: Check “Line Numbers” and click on “OK”

image

Now, when a query window is opened Line Numbers will be displayed:

image

Hope This Helps!

Vishal

If you like this post, do like my Facebook Page –> SqlAndMe
EMail me your questions -> Vishal@SqlAndMe.com
Follow me on Twitter -> @SqlAndMe

SQL Server – Difference between @@CONNECTIONS and @@MAX_CONNECTIONS

January 13, 2014 Leave a comment

@@MAX_CONNECTIONS in SQL Server returns maximum number of simultaneous user connections allowed. Maximum user connections allowed by SQL Server by default is 32,767; this number also depends on application and server hardware limits. This cam also be configured at server-level to avoid too many connections.

@@CONNECTIONS returns number of connection attempts (successful/failed) made to SQL Server since SQL Server is started. Since this include all attempts it can be greater than @@MAX_CONNECTIONS.

SELECT [ConnectionAttempts] @@CONNECTIONS,

       [MaximumAllowed] @@MAX_CONNECTIONS

Result Set:

ConnectionAttempts MaximumAllowed

394024473          32767

 

(1 row(s) affected)

As you can see from the example above number of connection attempts can be higher.

Hope This Helps!

Vishal

If you like this post, do like my Facebook Page –> SqlAndMe
EMail me your questions -> Vishal@SqlAndMe.com
Follow me on Twitter -> @SqlAndMe

SQL Server – How to change SQL Server ERRORLOG location

July 8, 2013 3 comments

By default SQL Server ERRORLOG is stored in "C:\Program Files\Microsoft SQL Server\InstanceFolder\MSSQL\Log" folder. The ERRORLOG location is configured as a startup parameter for SQL Server Service.

image

To change the location of ERRORLOG you need to modify the startup parameter -e.

For example, if you need to move logs to C:\Logs\ then replace the startup parameter as below:

Step 1:

Replace "-eC:\Program Files\Microsoft SQL Server\MSSQL11.SQL2012\MSSQL\Log\ERRORLOG"

to "-eC:\Logs\ERRORLOG"

Step 2:

Restart SQL Server Service to apply changes. The ERRORLOG will be created to "C:\Logs" after SQL Server is restarted.

 

To change location for SQL Server Agent Logs:

Location for SQL Server Agent Log can be changed using T-SQL or SQL Server Management Studio.

Method 1: To change SQL Server Agent Log location right click on "Error Logs" node and select "Configure"

image

Provide new location for Log file in "Error Log File" path:

image

Click on "OK" and restart SQL Server Agent to apply changes.

Method 2: To change log location using T-SQL

To change log location using T-SQL you can use below code:

USE [msdb]

GO

EXEC   msdb.dbo.sp_set_sqlagent_properties

       @errorlog_file = N'C:\Logs\SQLAGENT.OUT'

GO

Execute this code and restart SQL Server agent to apply changes.

Hope This Helps!

Vishal

If you like this post, do like my Facebook Page -> SqlAndMe
EMail me your questions -> Vishal@SqlAndMe.com
Follow me on Twitter -> @SqlAndMe

Follow

Get every new post delivered to your Inbox.

Join 271 other followers