This user account () has been banned from the forums

Forum Replies Created

Viewing 15 posts - 1 through 15 (of 44 total)

  • Reply To: Shrink Database Log Files One by One

    Find below script to generate the shrink all log files in single shot.

    DECLARE @dbname VARCHAR(256)

    DECLARE @logname VARCHAR(256)

    DECLARE @dbcursor CURSOR

    SET @dbcursor = CURSOR

    FOR

    SELECT DB_Name(database_id), [name]

    FROM sys.master_files

    WHERE [type] = 1

    OPEN @dbcursor

    FETCH NEXT

    FROM...

  • Reply To: Shrink Database Log Files One by One

    Find below script to generate the shrink all log files in single shot.

    DECLARE @dbname VARCHAR(256)

    DECLARE @logname VARCHAR(256)

    DECLARE @dbcursor CURSOR

    SET @dbcursor = CURSOR

    FOR

    SELECT DB_Name(database_id), [name]

    FROM sys.master_files

    WHERE [type] = 1

    OPEN @dbcursor

    FETCH NEXT

    FROM...

  • Reply To: GRANT EXECUTE for ALL stored procedures to User/Group

    Find below script to grant execute permission to user to all stored procedure in Databases

     

    ---- declare local variables

    DECLARE @StoreProcedure VARCHAR(200)

    ---- User Variable to store the User Id which need the...

  • Reply To: GRANT EXECUTE for ALL stored procedures to User/Group

    Find below script to grant execute permission to user to all stored procedure in Databases

     

    ---- declare local variables

    DECLARE @StoreProcedure VARCHAR(200)

    ---- User Variable to store the User Id which need the...

  • Reply To: Viewing backup history with T-SQL

    Find below backup history.

     

    Select T2.type, T2.is_copy_only, physical_device_name, user_name, database_name, server_name, backup_start_date, backup_finish_date, backup_size, DATEDIFF(MINUTE, backup_start_date, backup_finish_date) AS Total_Minutes

    --DATEDIFF(HOUR, backup_start_date, backup_finish_date)

    from msdb..backupmediafamily T1, msdb..backupset T2

    where T1.media_set_id = T2.media_set_id

    and T2.backup_start_date > getdate()...

  • Reply To: SQL SCript for Backup Compression

    Find below backup script take backup on specific DB and will create the folder.

    --Create target folder having +7 date

    Declare @targetdate datetime = getdate() + 14

    Declare @location nvarchar(3000) ='\\Servername\DB_Backup' + convert(nvarchar(10),@targetdate,112)...

  • Reply To: SQL SCript for Backup Compression

    Find below backup script take backup on specific DB and will create the folder.

    --Create target folder having +7 date

    Declare @targetdate datetime = getdate() + 14

    Declare @location nvarchar(3000) ='\\Servername\DB_Backup' + convert(nvarchar(10),@targetdate,112)...

  • Reply To: Check .mdf and .ldf file size using T-SQL

    Find below script will help to get mdf & ldf file size and backup file size also.

    USE MASTER

    Go

    SELECT @@SERVERNAME Servername,

    CONVERT(VARCHAR(25), DB.name) AS dbName,

    CONVERT(VARCHAR(10), DATABASEPROPERTYEX(name, 'status')) AS [Status],

    (SELECT COUNT(1) FROM sysaltfiles...

  • Reply To: Check .mdf and .ldf file size using T-SQL

    Find below script will help to get mdf & ldf file size and backup file size also.

    USE MASTER

    Go

    SELECT @@SERVERNAME Servername,

    CONVERT(VARCHAR(25), DB.name) AS dbName,

    CONVERT(VARCHAR(10), DATABASEPROPERTYEX(name, 'status')) AS [Status],

    (SELECT COUNT(1) FROM sysaltfiles...

  • Reply To: Fix orphaned users after restoring database to another server.

    Thank you for suggestion. Could you please share the script if you have . That will help for me.

    Thank you in Advanced !!

  • Reply To: Orphan users fpr all user databases

    Find below script will help for fix the orphan users for all DB's.

    Fix Orphan users in all databases

    SET NOCOUNT ON

    BEGIN

    declare @UserName sysname

    declare @NoOfUsers smallint

    declare @dbname varchar(50)

    declare @query varchar(2000)

    declare @query_1 varchar(2000)

    CREATE...

  • Reply To: Orphan users fpr all user databases

    Find below script will help for fix the orphan users for all DB's.

    Fix Orphan users in all databases

    SET NOCOUNT ON

    BEGIN

    declare @UserName sysname

    declare @NoOfUsers smallint

    declare @dbname varchar(50)

    declare @query varchar(2000)

    declare @query_1 varchar(2000)

    CREATE...

  • Reply To: Fix orphaned users after restoring database to another server.

    Find below script to fix the orphan users in SQL database.

    DECLARE @UserName nvarchar(255)

    DECLARE orphanuser_cur cursor for

    SELECT UserName = name

    FROM sysusers

    WHERE issqluser = 1 and (sid is not null and sid...

  • Reply To: inventory of sql server info

    Find below script will help to get the SQL server inventory details.

    create table #SVer(ID int,  Name  sysname, Internal_Value int, Value nvarchar(512))

    insert #SVer exec master.dbo.xp_msver

     

    declare @SmoRoot nvarchar(512)

    DECLARE @sn NVARCHAR(128)

    DECLARE @sa NVARCHAR(128)

    exec...

  • Reply To: Add column to subscriber table

    Find below script to add table into existing replication to generate the snapshot for newly added tables instead of complete snapshot.

    1. **Check value of Anonymous and sync

    sp_helpdistributor

    Use Publication_DB_Name

    GO

    select * from...

Viewing 15 posts - 1 through 15 (of 44 total)