December 13, 2007 at 4:17 am
[font="Arial"]Hi all
I am facing some problem in the following please tell me that what is wrong.[/font]
DECLARE @TableName nvarchar(Max),@Abbreviation nvarchar(100)
SET @Abbreviation='HH'
select CASE @Abbreviation
WHEN 'HH' THEN SET @TableName='Hotel_History'
WHEN 'HA' THEN SET @TableName='Hotel_Accomodation'
WHEN 'HD' THEN SET @TableName='Hotel_Dining'
WHEN 'HB' THEN SET @TableName='Hotel_Banquet_Conference'
WHEN 'HF' THEN SET @TableName='Hotel_Facilities_Services'
WHEN 'HV' THEN SET @TableName='Hotel_Virtual_Tour'
WHEN 'HG' THEN SET @TableName='Hotel_Gallery'
ELSE SET @TableName='NotMatch'
END
PRINT @TableName
Thanks
Warm Regards,
Shakti Singh Dulawat
Before printing, think about the environment
Do the impossible, and go home early.
December 13, 2007 at 4:41 am
Remove the SET= from the case as below ...
DECLARE @TableName nvarchar(Max),@Abbreviation nvarchar(100)
SET @Abbreviation='HH'
SELECT
@TableName =
CASE @Abbreviation
WHEN 'HH' THEN 'Hotel_History'
WHEN 'HA' THEN 'Hotel_Accomodation'
WHEN 'HD' THEN 'Hotel_Dining'
WHEN 'HB' THEN 'Hotel_Banquet_Conference'
WHEN 'HF' THEN 'Hotel_Facilities_Services'
WHEN 'HV' THEN 'Hotel_Virtual_Tour'
WHEN 'HG' THEN 'Hotel_Gallery'
ELSE 'NotMatch'
END
PRINT @TableName
______________________________________________________________________
Personal Motto: Why push the envelope when you can just open it?
If you follow the direction given HERE[/url] you'll likely increase the number and quality of responses you get to your question.
Jason L. SelburgDecember 13, 2007 at 4:43 am
Use:
DECLARE @TableName nvarchar(Max),@Abbreviation nvarchar(100)
SET @Abbreviation='HH'
select @TableName = CASE @Abbreviation
WHEN 'HH' THEN 'Hotel_History'
WHEN 'HA' THEN 'Hotel_Accomodation'
WHEN 'HD' THEN 'Hotel_Dining'
WHEN 'HB' THEN 'Hotel_Banquet_Conference'
WHEN 'HF' THEN 'Hotel_Facilities_Services'
WHEN 'HV' THEN 'Hotel_Virtual_Tour'
WHEN 'HG' THEN 'Hotel_Gallery'
ELSE 'NotMatch'
END
PRINT @TableName
Regards,
Andras
December 13, 2007 at 4:48 am
Hmmm, Jason managed to post his response between me refreshing to see if someone answered, and pasting my answer in. Witchcraft? 🙂
Andras
December 13, 2007 at 4:49 am
Nothing magical here, I'm just looking over your shoulder Andras. 😉
______________________________________________________________________
Personal Motto: Why push the envelope when you can just open it?
If you follow the direction given HERE[/url] you'll likely increase the number and quality of responses you get to your question.
Jason L. SelburgDecember 13, 2007 at 6:44 am
Thanks you both
Warm Regards,
Shakti Singh Dulawat
Before printing, think about the environment
Do the impossible, and go home early.
December 13, 2007 at 6:57 am
Great minds think alike... and, frequently, at the same time. 😉
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 7 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply