Category: SQL Server

  • Bug Fix: Property IsLocked is not available for Login ‘[sa]’. This property may not exist for this object, or may not be retrievable due to insufficient access rights

    Problem: Property IsLocked is not available for Login ‘[sa]’. This property may not exist for this object, or may not be retrievable due to insufficient access rights. (Microsoft.SqlServer.Smo)

     

    Solution: You will get the above error, in case of one of the below issue.

    1. SQL Server authentication mode is Windows Only
    2. SA Account is disable
    3. SA account is locked

    SQL Server authentication mode is Windows Only

    You can check the SQL Server authentication mode using below query.

    SELECT
    CASE
    SERVERPROPERTY(‘IsIntegratedSecurityOnly’)

    WHEN 1 THEN
    ‘Windows Authentication’

    WHEN 0 THEN
    ‘Windows and SQL Server Authentication’

    END
    as [Authentication Mode]

    If the authentication mode Windows, you have to change the authentication mode is Mix Mode. You can change the authentication mode by right click on Server Properties -> Security tab.
    This requires SQL Server Service restart.

    SA Account is locked/Disable

    You can execute below query to check whether SA account is locked or not. If the account is locked it will return 1 and 0 for un-locked.

    SELECT
    LOGINPROPERTY(‘sa’,
    ‘IsLocked’)

    You can investigate whether SA account is locked by bad Password using below query. It will return the count of consecutive failed login attempts

    SELECT
    LOGINPROPERTY(‘sa’,
    ‘BadPasswordCount’);

    GO

    Right click on SA account and check the SA account properties, check the below properties of the SA login whether it is disabled or locked.

    Execute the below script to unlock and enable the SA account

    ALTER
    LOGIN [sa] WITH
    PASSWORD=N’Password’,

    DEFAULT_DATABASE=[master],

    DEFAULT_LANGUAGE=[us_english],

    CHECK_EXPIRATION=OFF,

    CHECK_POLICY=OFF

    GO

    ALTER
    LOGIN [sa] ENABLE

    GO

  • How to setup schedule Maintenance Plan?

    Step 1: Launch SQL Server Management Studio and In the Object Explorer expand the Management folder.

    Step 2: Right click on the Maintenance Plans folder and select New Maintenance Plan.

     

    Step 3: Give the meaning full name to maintenance plan.


     

    Step 4: From the Toolbox drag and drop a Check Database Integrity Task, Rebuild Index Task, Update Statistics Task and place them vertically in the same order.

    Step 5: Connect the tasks together by dragging the arrow from one box to the other so they are connected as: Check Database Integrity Task – Rebuild Index Task – Update Statistics Task.


    Step 6 Right click on the each tasks and select the databases in maintenance plan.

    Step 7 Schedule a maintenance plan to run in off business hours.

     


     

  • How to check the Index Fragmentation in SQL Server?

    Step 1: Launch SQL Server Management Studio.

    Step 2: In the object explorer, right click on the database and select Reports -> Standard Reports -> Index Physical Statistics.

    Step 3: SQL Server Management Studio will generate a report showing information about the Table Names, Index Names, Index Type, Number of Partitions and Operation Recommendations.

    Step 4: Repeat the above steps to check the fragmentation of all user databases.

     

    One key value that is provided in the report is the Operation Recommended field. Any value of Rebuild is an indication that the index is fragmented.

    By expanding the # Partitions field, you can see the % of fragmentation for a given index.

     

    Report looks like below.

    Fragmentation in the AI era: vector indexes

    The fragmentation thinking above now applies to a new index type. SQL Server 2025 added a native VECTOR data type (generally available) for storing embeddings alongside relational data, with DiskANN-based vector indexes for similarity search still in preview as of early 2026 — check the current docs before planning around them. The maintenance mindset does not change: whatever the index type, an unmaintained index is a slow query waiting to happen. For how those embeddings actually get retrieved: The 9 Types of RAG, Explained

  • How to check waits in SQL Server 2000?

    Today I got a comment, how to check the wait statistics in SQL Server 2000. You can query sysprocesses table and use the DBCC SQLPERF to get the wait statistics in SQL Server 2000.

    select top 5* from sysprocesses
    dbcc sqlperf(‘waitstats’)

    Wait Statistics Image

  • How to use RunAs command for SSMS if option does not exist?

    Problem

    As a best practice in the industry, a DBA often has two logins that are used to access SQL Server; one is their normal Windows login and the other is an admin level login account which has sysAdmin rights on the SQL Server boxes. In addition most of the time the SQL Server client tools are only installed on the local desktop and not on the SQL Server Production Box. In order to use the different login to connect to SQL Server using SSMS you need to use the “Run as” feature. What do you do in the case of Windows 7 or Windows Vista where you can’t find the Run As Different User option.

    Solution

    http://www.mssqltips.com/sqlservertip/2617/how-to-use-runas-command-for-ssms-if-option-does-not-exist/