Error : Property Size is not available for Database "[tempdb]"
Today when I clicked Properties of tempdb in SSMS, I got the error message below:At first I thought the database has size problem, so I extended the file size of tempdb, but I was still not able to see...
View ArticleUse application lock to synchronize T-SQL code
Application lock can be used to synchronize T-SQL code, you can control if the session is able to run the t-sql code at same time, it is like the lock keyword in C#.1. Get lockyou can get application...
View Articlelog shipping restore job failed on secondary server
Several Situation will cause the log shipping restore job failed on secondary server1. Restore job is not able to access the transaction log backup file. a) Other process is accessing the backup...
View Article"Failover Partner" keyword in connection string - Q&A
1. How to connect client to a Database Mirroring Session with failover awareA: add FailoverPartner keyword in the connection string, for instance:"Server=sq01;Failover Partner=sq02; Database=mydb;...
View ArticleOne Database Mirror disconnected case
Today I got a database mirror case, I was told the all databases were in disconnected\in recovery status on both primary and mirror server, it is a dev environment.Here just share my troubleshooting...
View Articleis count(1) faster than count(*)?
Recently I saw a post regarding the count(1) and count(*)http://www.sqlservercentral.com/articles/T-SQL/102474/the post said "You know that doing COUNT(*) on a table with a lot of columns and a lot of...
View ArticleEnable Instant File Initialization to accelerate database restore
Today my colleague come to me and ask me why her database restore query was hang. She was going to restore a database with 200GB data file and 11GB log file.She had run the restore command for about 15...
View ArticleList all mapping users of SQL login account
Find a useful system store procedure to list all mapping user of SQL login account.sp_msloginmappings @Loginname , @Flags@loginname: the login account name, If loginname is not specified, results are...
View ArticleGet SQL Command Compile time
1. SET STATISTICS TIME ONIt not only tell you the compile time of sql command, but also show you the execution times. when you enable it, all the sql command in the current session will be impacted, so...
View ArticleSQL Server 2012 Express installation failed issue
I got an strange error when installing SQL Server 2012 ExpressEnvironment:Window Server 2008 R2 Enterprise + SP1Microsoft Visual Studio 2012 installed.Net 4.5 framework InstalledWhen I double clicked...
View ArticleAlwayson availability groups failover monitoring - Part 1
There are a lot of ways to monitor AG, sql server errorlog, window event log, cluster log......, here I list another way to check and monitor AG state with the log files below:1. AlwaysOn Health...
View ArticleGap issue in SQL Server 2012 IDENTITY column
Found a gap issue when using IDENTITY column in SQL Server 2012, every time I restarted sql server service, the current identity number will jump to 1000. here is the repro scriptCREATE TABLE MYTEST...
View ArticleFind out orphan database file on disk
Sometimes you detach databases, or you delete a database which is in restoring status, the data and log file will not be removed from local disk. if you forget the files, It might cause issues1. The...
View Articletrace flag for backup and restore operation
1. 3004show the internal backup/restore operation for every step.ex.dbcc traceon(3004,3605,-1)GO3605 means output the message to errorlog. you can use 3604 to direct the output to client, but it...
View ArticleSQL Server 2012 AlwaysOn Availability Groups setup scripts - Part 3
4. Setup 2 nodes alwayson availability group a) Enable alwayson on both 2 nodesenable-sqlalwayson -Path "SQLSERVER:\SQL\SQL2012-01\DEFAULT"enable-sqlalwayson -Path...
View ArticleSQL Server 2012 AlwaysOn Availability Groups setup scripts - Part 2
3. Install SQL Instance a) Configure the firewall setting on both 2 nodes.echo Default Instancenetsh advfirewall firewall add rule name="SQLServer" dir=in action=allow protocol=TCP localport=1433...
View ArticleSQL Server 2012 AlwaysOn Availability Groups setup scripts - Part 1
Here are some scripts which can be used for setting up 2 nodes AlwaysOn Availability Groups, you can make your own automation script based on them.Environment :NameIP...
View Articleuse Table Variables in transaction
when using table variable, please note table variable doesn't support transaction rollback. here is the words from BOLBecause table variables have limited scope and are not part of the persistent...
View ArticleLimit running Powershell script under specific path with AppLocker
Say if you have a management server or a script repository server, sometimes users save/test/run their script from different path, it is different to maintain the script version, and it is hard to...
View Article