Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Case Statement Help 1

Status
Not open for further replies.

sila

Technical User
Aug 8, 2003
76
0
0
GB
Hi

Based on the sql statement below how do I get the address fields to show N/A when the ShowAddress field is 0?

Code:
ALTER PROCEDURE dbo.CES_MEMSelectMemberIDAddress

	(
		@MemberID as varchar(10)
	)

AS
	/* SET NOCOUNT ON */
	 SELECT     Address1, Address2, Address3, Address4, Postcode, Telephone, OfficeTelephone, Email, Fax, OfficeFax, Website, ShowAddress, Mobile
	 FROM         dbo.Members
	 WHERE     (UserID = @MemberID)
RETURN

Thanks.
 
Code:
SELECT
  CASE WHEN showaddress = 0 THEN 'n/a' ELSE adddress1 END AS address1,
  CASE WHEN showaddress = 0 THEN 'n/a' ELSE adddress2 END AS address2,
  ...
FROM dbo.members
WHERE userid = @memberid

--James
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top