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
Interview question and answer by:
Virendradugar | Posted on: 9/15/2009 | Category:
SQL Server Interview questions | Views: 1931 |
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
Found interesting? Add this to: