Filter
  • make all the databases readonly or readwrite

    create procedure sp_READONLY_READWRITE @dbname varchar(50) --NULL=all DBs other than mast, pass database name for sigle,
    , @RW int -- 0=READONLY and 1=READWRITE
    as
    BEGIN
     declare @name varchar(50)
     declare @sql varchar(250)
     select @sql= 'ALTER DATABASE ' + @name + ' SET READ_ONLY WITH NO_WAIT'
    -- print @dbname
     if @dbname is null
      DECLARE db_cursor CURSOR

  • T-SQL: Query to fetch SQL jobs and its schedule

    Below query fetch all the sql jobs and its schedule:

    SELECT j.name as jobname, js.next_run_date as ScheduleDate, js.next_run_time as ScheduleTime

    FROM msdb.dbo.sysjobs AS j INNER JOIN -- sysjobs talbe whch hold job details

    msdb.dbo.sysjobschedules AS js ON j.job_id=js.job_id -- sysjobschedules table to fech Schedule details

    WHERE j.enabled= 1 -- All enabled Job Only

     

    ORDER BY js.next_run_date desc

     

  • T-SQL: How to rename SQL server database Name

    There are two way to rename SQL Server database

    1. Using sp_renameDB stored procedure and

    2. by Using ALTER DATABASE command 

    1. sp_renamed

    EXEC sp_renameDB 'oldDBName','newDBName'

    2. Alter database

    --Rename the Database <OldDBName> to <NewDBName>
    ALTER DATABASE <OldDBName> MODIFY NAME
    <NewDBName>
    GO

  • How to start SQL Server in single user mode in SQL Server 2008

    How to start SQL Server in single user mode in SQL Server 2008.

     

    Step 1: Open SQL Server configuration manager.

     

    Step2: On Left pan, point to “SQL Server Services”

     

    Step3: Then, In right pan select “SQL Server(servername)”.

     

  • Get the Domain Group List of a use alias and all other details of a user

    C:\>net user /DOMAIN <username>

    C:\>net user <username> /DOMAIN

    This command will list you complete information of a user like:

    User name                    <username>

    Full Name                   
    Comment
    User's comment
    Country/region code          000 (System Default)
    Account active               Yes
    Account expires              Never

  • What is SQL

    SQL is 5th generation language.

Additional information