Posts

Showing posts from March, 2018

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....

Interview Tips

What are phantom reads? PHANTOM READS: Data getting changed in current transaction by other transactions is called Phantom Reads. New rows can be added by other transactions, so you get different number of rows by firing same query in current transaction. What is Multisubnet Failover in ALWAYSON ? If you are using client libraries that support the MultiSubnetFailover connection option in the connection string, you can optimize availability group failover to a different subnet by setting MultiSubnetFailover to “True” or "Yes", depending on the syntax of the provider you are using. The MultiSubnetFailover connection option only works with the TCP network protocol and is only supported when connecting to an availability group listener and for any virtual network name connecting to SQL Server 2017. An example of the ADO.NET provider (System.Data.SqlClient) connection string that enables multi-subnet failover is as follows: Server=tcp:AGListener,1433;D...

2012 PowerShell Install

2012 install <# .SYNOPSIS The purpose of this script is to gather details from the DBA installer to customize their SQL Server install.  This script will produce a configuration ini file and will launch a SQL Server silent Install.  After the silent instal, a basic check is done to ensure the new instance is created.  If the new instance exists, the port number is changed from dynamic to static, firewall rules are updated with the new port information, sa account is disabled, and the polkj11 account is created. .DESCRIPTION This script will gather the following information: 1.) Named or Default instance 2.) SQL Server Service Account Name 3.) SQL Server Service Account Password 4.) SQL Agent Service Account Name 5.) SQL Agent Service Account Password 6.) Integrated SErvices Service Account Name 7.) Integrated Service Service Account Password 8.) Alternate SA account Name 9.) SA / Alternate SA Password 10.) DBA ...