What does this return ?
declare @adress varchar = 'India'
select @adress

 Posted by Mcadeepuraj on 5/4/2011 | Category: Sql Server Interview questions | Views: 5621 | Points: 40
Select from following answers:
  1. india
  2. I
  3. gives Error
  4. no error
  5. All Above

Show Correct Answer

Source: MIND Infotech Interview | Asked In: Interviews | Alert Moderator 

Comments or Responses

Posted by: Kishork80 on: 5/5/2011 | Points: 10
good observation
Posted by: Lakhwinder.ghuman on: 5/6/2011 | Points: 10
The result would be I bcoz at time of declaration the size is not specified so by default it will save 1 character.
Posted by: Shoeb2222 on: 6/22/2011 | Points: 10
When I am trying to run the above two statement in SQL server 2008, it is throwing below error.

Msg 139, Level 15, State 1, Line 0
Cannot assign a default value to a local variable.
Msg 137, Level 15, State 2, Line 2
Must declare the scalar variable "@adress".

Posted by: Mcadeepuraj on: 6/22/2011 | Points: 10
in sql 2008, it does not give error, may be you used previous version.

Login to post response