Skip to main content

Posts

Showing posts from April, 2007

Workaround for 'Divide by zero error encountered'

Today I just want to write a sample explaining the workaround for 'Divide by zero error encountered.' error in SQL Server. Sample Table Structure for demo purpose Create Table dbo.TestDivideByZero ( WebSite varchar(50), NumOfHits int, Income int ) Go Insert dummy records Insert into dbo.TestDivideByZero values ('a.com', 100, 20) Insert into dbo.TestDivideByZero values ('b.com', 10, 0) Insert into dbo.TestDivideByZero values ('c.com', 300, 25) Insert into dbo.TestDivideByZero values ('d.com', 1300, 225) Go Query to produce 'Divide by zero error encountered.' error Select WebSite, NumOfHits / Income from dbo.TestDivideByZero Go This would throw the below error: Msg 8134, Level 16, State 1, Line 1 Divide by zero error encountered. Workaround Make use of NULLIF function. Like, if the value is 0 then return NULL. For better understanding execute the below query and see it for yourself. Select WebSite, NumOfHits / NullIf(Income,0) as ColumnNam

Arithmetic overflow error converting expression to data type int.

Today I was trying to join two table each having approximately 5 Lakhs records in one of my SQL Server 2005 database. I was trying to find the count of some field when this arithmetic overflow error was thrown. Arithmetic overflow error converting expression to data type int. I understood that the calculation has exceeded the maximum INT range. For better understand on this error check out this SQL Books online article and/or this KB article . The work around which did the trick for me is, instead of "Count" I changed it as "Count_big".

Top 20 things programmers say to testers!

I was going through the "Top 20 things Programmers says to Testers!" . Its really funny and brought back lot of memories. Out of the 20, i need to admit I use these excuses very often :) 18. "It worked yesterday!" 12. "You must have a wrong version" 1. "It works on my machine" The other excuses which I use or heard people using it are: 1. The issue isn't reproducable. 2. It's designed to work that way! 3. You know we have done it as a value add ourself! there is no spec for this. 4. It's been fixed long time back. May be you are looking into a wrong version! 5. You know its not because of our layer! It's an error in the "Service Layer" which another team needs to look at. 6. I don't think its a show stopper. How about fixing it in the next release? Do you have a say on this?

A Saturday with Zoho Writer!

Today I thought of trying my luck with Zoho Writer and write my feedback about that. So is this post :) Just a thought: Actually I am surprised that almost all of zoho's product have different UI's. Won't it look good if they create a uniform look and feel across their products? Most of the Products have Single Sign On facility: It's really nice to see that they have done SSO (single sign on) authentication for their products. It means, previously I have registered with Zoho Sheets and now to work with Zoho Writer I can make use of the same login. How to enable SSO for a zoho product? 1. First login to any of their product (zoho sheet, zoho writer, zoho show, zoho project, zoho creator, zoho planner, zoho wiki and zoho chat). Yes you need to register once in any of their product. 2. In the header of the application you can see "My Account" link. Click on it to see a screenshot as shown below for your account information. 3. Now lets assume that you need to en

AutoEventWireup

<%@ Page language="c#" Codebehind="WebForm1.aspx.cs" AutoEventWireup="true" Inherits="Sample2003Application.WebForm1" %> AutoEventWireup -- It's a boolean field. By default in VS.NET 2003 it would be "false". More over this attribute is applicable only for applications which are created via VS.NET 2003. If it's set to "True", the ASP.NET runtime does not require events to specify event handlers like Page_Load etc., Once you create a new webform in VS.NET the 'AutoEventWireup' attribute of that page would be false. Open the code behind file and check out the 'InitializeComponent' it would be something like this: private void InitializeComponent() { this.Load += new System.EventHandler(this.Page_Load); } Within Page_Load even print a message into the screen. private void Page_Load(object sender, System.EventArgs e) { Response.Write("We are in Page Load event."); } This message "We ar

Export data from SQL Server to Excel without using SSIS or DTS

Normally for exporting data from SQL Server to Excel one would use DTS (SQL 2k) or SSIS (SQL Server 2005). For some reason if at all you want to do it via query read on: Step 1: Execute the code snippet Exec sp_configure 'show advanced options', 1; Go Reconfigure; Go Exec sp_configure 'Ad Hoc Distributed Queries', 1; Go Reconfigure; Go Step 2: Create the excel file and then add the headings in the .xls file. [Important] The heading should be the same as that of the table columns. Insert into Openrowset ('Microsoft.Jet.OLEDB.4.0', 'Excel 8.0;Database=c:\VadivelTesting.xls;' , 'Select * from [ProductInfo$]') Select ProductID, ProductName from dbo.tblProducts Points which might interest you: 1. As long as the file is within your C: drive this sample would work. If at all your database is in a different machine from that .xls file you need to change Database=c:\VadivelTesting.xls; to UNC path. For example, Database=\\Servername\shareName (And need

ToonDoo from Jambav ... 2

I came to know about ToonDoo from D. Rajendran (who is a Product Manager in Jambav) and I am glad he introduced this to me. I created couple of toons and have blogged about it here . I really liked this toonDoo concept and i am playing with it for past 2 days like a kid :) Actually I wanted to write about "Jambav" in June '06 itself. But as I was bit busy couldn't do that (believe me i was busy only lol). Now somebody has beaten me and has interviewed "Rajendran Dandapani" about him and Jambav . He has spoken about "What is Jambav and why that name?", "about the motivation to start Jambav", "About him and his responsibilities", "Key technologies used", "their business model" etc., I strongly recommend everybody to go through it without fail. That said, there are few things which I am not sure about this tool ... 1. How much load can their server take? Because very often I find that the server is down (more t

ToonDoo from Jambav ...

Jambav (backed by Adventnet ) has launched another cool tool few days back by name " ToonDoo " (Cartoon Strip Creator). You can check my really exciting works below :) [ Updated the copy: As usual there were lots of typo in my Indian Cricket toon which I have changed it now]. BTW, at present there is a contest at ToonDoo . Create any number of toon and show the world what you are thinkinng abt it. What are you waiting for? Go get registered and start playing with it. Techcrunch has a good write up on ToonDoo here Technorati tags: Jambav , Cricket , ToonDoo , Kids