Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Performing an IF statement in a SQL Statement.
Message
 
To
25/02/2005 12:02:24
Mike Cole
Yellow Lab Technologies
Stanley, Iowa, United States
General information
Forum:
ASP.NET
Category:
Databases
Environment versions
Database:
MS SQL Server
Miscellaneous
Thread ID:
00990593
Message ID:
00990604
Views:
13
>What I need to do is create a view that contains a name field. If the Full Name doesn't exists, I want to combine the rest of the fields to return a full name. If the last names are the same, I want to return JOHN AND SALLY SMITH. If the last names are not the same, I want to return PAYTON MANNING / MARVIN HARRISON.

Mike,

Perhaps something like this would work:
SELECT ISNULL(FullName, 
              Name1First + ' ' +
                 (CASE WHEN Name1Last=Name2Last THEN 
                            'AND ' + Name2First
                       ELSE Name1Last + ' / ' + Name2First + ' '
                  END) + Name2Last) AS NewFullName
Laterness,
Jon

P.S. I just realized this was in the .Net forum. My response was based on T-SQL syntax for SQL Server.
Jon Rosenbaum
Devcon Drummer
Previous
Reply
Map
View

Click here to load this message in the networking platform