Posts

Showing posts from December, 2021

dbatools download and installation

Image
Click on the below link( dbatools ) and found "DownloadZip" under CODE. Once the zip folder is downloaded it will download as  "dbatools-development". and extract it. After that change the folder name from "dbatools-development" to "dbatools". And sometimes there is a possibility that dbatools folder contains another dbatools-development folder with in the folder,if that is the case please make there is only one "dbatools" folder not any duplicate folders with in it. dbatools In the search space search with "ISE" and choose PowerShell and run as administrator and run the below command. And it will give the paths of modules like below. You can find these many paths for modules and copy the dbatools folder from source to " C:\Program Files\WindowsPowerShell\Modules " folder  and run the below command in PowerShell and you can see the progress of installation and will successfully install it.

New-NetFirewallRule

Image
 The below command will allow fire wall rule to get results through ping command and to access the server remotely.

Could not drop login 'loginname' as the user is currently logged in.

Image
 I  go the below error in one our environments. Below are the troubleshooting steps. Run the below command find the session id that are using by that particular session KILL all the session KILL SELECT session_id FROM sys.dm_exec_sessions WHERE login_name = 'LoginName' And then run the below command USE [master] GO DROP LOGIN [LoginName]

Finding the free space in the data file of database in SQL Server.

The below query will provide us the amount of free space that exist at database data file level. CREATE TABLE # FileSize (dbName NVARCHAR( 128 ), [FileName] NVARCHAR( 128 ), physical_name varchar ( 150 ), type_desc NVARCHAR( 128 ), CurrentSizeMB DECIMAL ( 10 , 2 ), FreeSpaceMB DECIMAL ( 10 , 2 ) ); INSERT INTO # FileSize (dbName,[FileName],physical_name,type_desc, CurrentSizeMB, FreeSpaceMB) exec sp_msforeachdb 'use [?]; SELECT DB_NAME() AS DbName, name AS FileName, physical_name, type_desc, size/128.0 AS CurrentSizeMB, size/128.0 - CAST(FILEPROPERTY(name, ''SpaceUsed'') AS INT)/128.0 AS FreeSpaceMB FROM sys.database_files WHERE type IN (0,1) and type_desc=''ROWS'';' ; SELECT * FROM # FileSize WHERE dbName NOT IN ( 'distribution' , 'master' , 'model' , 'msdb' ) and type_desc = 'ROWS' and physical_name LIKE 'E:\%' --A...

The subscription(s) have been marked inactive and must be reinitialized. NoSync subscriptions will need to be dropped and recreated. (Source: MSSQLServer, Error number: 21074),REPLICATION

Distribution Agent job failed with below erro message and the below workaround fixed the issue in my environment Error messages: The subscription(s) have been marked inactive and must be reinitialized. NoSync subscriptions will need to be dropped and recreated. (Source: MSSQLServer, Error number: 21074) USE Distribution GO SELECT STATUS,* FROM [dbo].[MSsubscriptions] WHERE PUBLISHER_DB= 'PublisherDBNameHere' use distribution go update MSSubscriptions set [status] = 2 WHERE PUBLISHER_DB= 'PublisherDBNameHere' And to check thestatus after above command use distribution go exec sp_browsereplcmds