Which of the following queries generates an error when executed?
DECLARE @x VARCHAR(10), @y VARCHAR(10)
SET @y = ''
SELECT @x/0 -- query 1
SELECT @x/2 -- query 2
SELECT @y/0 -- query 3
SELECT @y/2 -- query 4

 Posted by Virendradugar on 9/15/2009 | Category: Sql Server Interview questions | Views: 4273
Answer:

Answer: 3


Explanation: Queries 1 and 2 return NULL since @x is undefined. Query 4 returns 0 since the string '' is implicitly converted to 0. Query 3 returns a divide by 0 error.


Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Login to post response