This user account () has been banned from the forums
Viewing 15 posts - 1 through 15 (of 44 total)
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...
March 30, 2025 at 8:45 am
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...
March 30, 2025 at 8:44 am
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...
March 30, 2025 at 8:35 am
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...
March 30, 2025 at 8:34 am
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()...
March 6, 2025 at 1:47 pm
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)...
March 6, 2025 at 1:45 pm
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)...
March 6, 2025 at 1:41 pm
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...
March 6, 2025 at 1:39 pm
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...
March 6, 2025 at 1:37 pm
Thank you for suggestion. Could you please share the script if you have . That will help for me.
Thank you in Advanced !!
March 4, 2025 at 6:08 am
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...
March 4, 2025 at 5:54 am
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...
March 4, 2025 at 5:54 am
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...
March 4, 2025 at 5:50 am
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...
March 3, 2025 at 5:26 am
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...
March 3, 2025 at 5:09 am
Viewing 15 posts - 1 through 15 (of 44 total)