This problem is actually quite easy to solve, using this: NULLIF(Divisor,0) NULLIF will check whether the Divisor is equal to zero. If it is, then it specifies the value to be NULL therefore it won’t trigger the SQL Server error message. More info: http://msdn.microsoft.com/en-us/library/ms177562.aspx
Archive for May, 2009
Division By Zero Error
Posted in SQL Server, tagged tsql, workaround on 28 May 2009 | Leave a Comment »
How To Find The SQL Server Port Number
Posted in SQL Server, tagged administration on 26 May 2009 | Leave a Comment »
SQL Server 2005/2008: Click open the SQL Server Configuration Manager > SQL Server 2005 Network Configuration> Protocols for MSSQLSERVER On the right panel, double click TCP/IP > IP addresses tab. SQL Server 2000 : Go to SQL Server Client Network Utility, select the instance, make sure you’re on the General tab, select TCP/IP and click [...]
How To Fix A Suspect Database – SQL Server 2005
Posted in SQL Server, tagged suspect database, troubleshooting on 25 May 2009 | 1 Comment »
I was running a resource-intensive reindexing script when my CPU froze for about 15 mins without any sign of “thawing”. Being an impatient idiot, I reached for the power button to reboot. Back to the SSMS….. aaaand the database has gone suspect, GREAT! *with sarcasm* Well, since this is a non-production database, there’s no issue [...]
Uninstall SQL Server 2008
Posted in SQL Server, tagged administration, installation on 24 May 2009 | 1 Comment »
This is a bit tricky! I was trying to uninstall the SQL Server 2008 on my local server. Buuut… I couldn’t find the remove option. Add/Remove Program? Not an option, I might end up with nasty, dirty registry and corrupted installation. Setup.exe? Strangely doesn’t have a remove option (this is SQL2008 RTM). So I asked [...]
Disappearing Task Manager Tabs
Posted in Windows, tagged display, task manager on 21 May 2009 | Leave a Comment »
Is your Task Manager looking like this? Been wondering where the tabs are? Just double click on the area pointed by the arrow. Look who’s back!
Installing Adventureworks Database
Posted in SQL Server, tagged adventureworks, installation on 19 May 2009 | Leave a Comment »
If you’re as silly as me and you’ve been wondering where the hell the Adventureworks database is after you run the msi file, look here. My light bulb was clicked recently and I found the solution here: http://msdn.microsoft.com/en-us/library/aa992075.aspx In a nutshell, here’s what you have to do (after you downloaded and ran the file): 1. [...]
Change Default Schema In SQL Server 2005/2008
Posted in SQL Server, tagged schema, security on 15 May 2009 | Leave a Comment »
I recently found out that some schemas in my SQL2005 box are not of the default dbo (this is apart from some pre-determined schemas that we have). This seems to happen when I run sp_adduser to add a login as a user of a particular database. CREATE LOGIN [DOMAIN\mylogin] FROM WINDOWS GO USE MyTestDB GO [...]
Unlock Login in SQL 2005/2008
Posted in SQL Server, tagged login, security on 14 May 2009 | Leave a Comment »
Without changing password: ALTER LOGIN [login] WITH CHECK POLICY = OFF; ALTER LOGIN [login] WITH CHECK POLICY = ON; GO With password change: ALTER LOGIN [login] WITH password =’*****’ UNLOCK; GO http://msdn.microsoft.com/en-us/library/ms189828.aspx
How to convert datetime data type
Posted in SQL Server, tagged tsql, workaround on 10 May 2009 | Leave a Comment »
I must admit I dislike the SQL datetime data type – it’s long, ugly and not always readable. So I totally understand why some people will go a distance to make this type easier for them (to read, that is). Well, the good news is there is a way to convert datetime format to other [...]