Posts

Showing posts from September, 2019

database mirroring queries

SELECT db.name, m.mirroring_role_desc,mirroring_state_desc,mirroring_safety_level, mirroring_partner_name,mirroring_partner_instance,mirroring_witness_name,mirroring_witness_state_desc,* FROM sys.database_mirroring m JOIN sys.databases db ON db.database_id = m.database_id where db.name='DBNamehere' SELECT     databases.name AS DatabaseName,    database_mirroring.mirroring_state_desc,    database_mirroring.mirroring_role_desc,    database_mirroring.mirroring_safety_level,    database_mirroring.mirroring_safety_level_desc,    database_mirroring.mirroring_safety_sequence,    database_mirroring.mirroring_witness_name,    database_mirroring.mirroring_witness_state,    database_mirroring.mirroring_witness_state_desc    FROM sys.database_mirroring     INNER JOIN sys.databases ON databases.database_id=database_mirroring.database_id WHERE databases.database_id > 4 

Script out table along with Data in SQL Server

Image
Right click on any d atabase and --->Task-->Generate Scripts and you can see the wizard like below. Now click on Next button, you will get the below image, choose required table or all the tables based on your requirement . After you click on next button,it will show you below image and ask for the options like  do you want to scipt ou the info to file or new query editor winow. In my case i have chosen to new query editor window. And you can also see an advanced tab where you can level schema level permissions. After you click on Advanced button, change this below option and it will script out table with data. Once you click on okay and go next this will generate a table with data.

How to get the system info of server

---sytem information msinfo32--> provide system information. dxdiag--> Whether system is VM or not

How to take a backup of Database in MongoDB

Image
The below command will take teh backup of "learn" database in  MongoDB. You have to run this sepately by executing "mongodump". Please find the below steps 1) First i figure out where i have installed Mongodb, it is the C:\Program Files\MongoDB\Server\4.0\bin 2) Then go that folder  by using "CD" command 3) chose "mongodump" and provide parameters like --db --out backup --Out command will create a backup folder in the same drive, it will dump all the documents to that particular folder And the backup files look like below(as mentioned in the below image) If you want to take the same backups to another drive provide the path like below.
Image
The below command will drop all the databases at at time in MongoDB.