Posts

MongoDB Commands

Export collection without ID field: mongo --host dfwlnpmgdb-03:27018 cpq_prod --quiet --eval "db.PricingTable.find({}, {_id: 0}).forEach(printjson)" > /home/kolguk01/export/out.json Create/DROP Index: Note: Always use background set to true while creating the indexes db.css.dropIndex("ts_365_days") db.css.dropIndex("url_1_src_1") db.css.dropIndex("_id_") db.css.createIndex( { "ts" : 1}, {"name" : "ts_365_days", "expireAfterSeconds" : 31536000,background : true}) db.css.createIndex( { "url" : 1, "src" : 1}, {"name" : "url_1_src_1", "unique" :true,background : true}) db.css.createIndex( { "_id" : 1}, {"name" : "_id_" ,background : true}) Select documents without the _id field db . collection . find ({}, { _id : 0 }) How to configure Replica set in MongoDB Step 1 : In th...

SQL Slipstream Installation

Steps for the Slipstream Installation Here are the steps: 1. Copy your original SQL Server 2008 R2 source media to C:\SQLServer2008R2_SP1 2. Download the SQL Server 2008 R2 SP1 packages from  here . You need to download all Service Pack 1 architecture packages: SQLServer2008R2SP1-KB2528583-IA64-ENU.exe SQLServer2008R2SP1-KB2528583-x64-ENU.exe SQLServer2008R2SP1-KB2528583-x86-ENU.exe 3. Extract each of the  SQL Server 2008 SP1  packages to C:\SQLServer2008R2_SP1\SP as follows: SQLServer2008R2SP1-KB2528583-IA64-ENU.exe /x:C:\SQLServer2008R2_SP1\SP SQLServer2008R2SP1-KB2528583-x64-ENU.exe /x:C:\SQLServer2008R2_SP1\SP SQLServer2008R2SP1-KB2528583-x86-ENU.exe /x:C:\SQLServer2008R2_SP1\SP Ensure you complete this step for all architectures to ensure the original media is updated correctly. 4. Copy Setup.exe from the SP extracted location to the original source media location. Here is the robocopy command: robocopy C:\SQLServer2008R2_SP1\SP C:\SQLSer...

MS SQL Server Tips

Image
Unable to Shrink the DataFile If you are unable to shrink the datafile then try the following Error :  File ID 3 of database ID 8 cannot be shrunk as it is either being shrunk by another process or is empty. DBCC execution completed. If DBCC printed error messages, contact your system administrator. Solution:   Add at least 2-3 MB to the data file and start shrinking again. Index Fragmentation Level SELECT distinct dbschemas.[name] as 'Schema', dbtables.[name] as 'Table',  dbindexes.[name] as 'Index', indexstats.avg_fragmentation_in_percent, indexstats.page_count, i.rowcnt as 'totalrows' FROM sys.dm_db_index_physical_stats (DB_ID(), NULL, NULL, NULL, NULL) AS indexstats INNER JOIN sys.tables dbtables on dbtables.[object_id] = indexstats.[object_id] INNER JOIN sys.schemas dbschemas on dbtables.[schema_id] = dbschemas.[schema_id] INNER JOIN sys.indexes AS dbindexes ON dbindexes.[object_id] = indexstats....