Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8395783
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T20:23:16+00:00 2026-06-09T20:23:16+00:00

Sorry for the stupid question but I am fairly new to SQL and I’m

  • 0

Sorry for the stupid question but I am fairly new to SQL and I’m trying to do something really simple. I have create a view made up of 3 tables and it works perfectly. However I require some of the fields to use some form of formatting. I’m using the SQL Server Management Studio GUI to create this view.

I have 2 columns in the view that require validation: Gender and DOB

The gender contains either ‘M’, ‘F’ or blank and I need to change this in the view to output 'Male' or 'Female'.

The DOB contains an unformated string of date I need to format that into DD/MM/YYYY.

Where should I create this validation, in the interest of laying all of my cards on the table here is the create view script:

CREATE VIEW [dbo].[PMIPatient]
AS
   SELECT     
      dbo.refPasPatientRec8Master.Patient_Internal_number AS HospitalNumber, 
      dbo.refPasPatientRec1Master.[H+C_Number] AS NHSNumber, 
      dbo.refPasPatientRec1Master.Patient_Title AS Salutation, 
      dbo.refPasPatientRec1Master.Surname, 
      dbo.refPasPatientRec1Master.Forenames AS Forename, 
      dbo.refPasPatientRec1Master.Sex_Code AS Gender, 
      dbo.refPasPatientRec1Master.Date_of_Birth AS Dob, 
      dbo.refPasPatientRec1Master.Date_of_Death AS Dod, 
      dbo.refPasPatientRec1Master.Address_Line_1 AS Address1, 
      dbo.refPasPatientRec1Master.Address_Line_2 AS Address2, 
      dbo.refPasPatientRec1Master.Address_Line_3 AS Address3, 
      dbo.refPasPatientRec1Master.Address_Line_4 AS Address4, 
      dbo.refPasPatientRec1Master.[Postcode/Pseudo_postcode] AS Postcode, 
      dbo.refPasPatientRec8Master.Patients_Phone_Number AS Telephone1, 
      dbo.refPasPatientRec39Master.Work_Telephone_Number AS Telephone2, 
      dbo.refPasPatientRec1Master.GP_Code AS GPGMCode, 
      dbo.refPasPatientRec1Master.Death_Indicator AS deceasedFlag
FROM         
      dbo.refPasPatientRec1Master 
INNER JOIN
      dbo.refPasPatientRec39Master ON dbo.refPasPatientRec1Master.Patient_Internal_number = dbo.refPasPatientRec39Master.Patient_Internal_number 
INNER JOIN
      dbo.refPasPatientRec8Master ON dbo.refPasPatientRec1Master.Patient_Internal_number = dbo.refPasPatientRec8Master.Patient_Internal_number
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T20:23:17+00:00Added an answer on June 9, 2026 at 8:23 pm

    All this is assuming your using MS-SQL!

    To change the return value of your Sex_Code then use a CASE statement. See this link for more information.

    Change this:

    dbo.refPasPatientRec1Master.Sex_Code AS Gender
    

    To this:

    CASE dbo.refPasPatientRec1Master.Sex_Code
         WHEN 'M' THEN 'Male' 
         WHEN 'F' THEN 'Female'
         ELSE 'Unknown'
    END AS Gender
    

    To format your Date_of_Birth value then use the CONVERT method to convert it to an NVARCHAR with the specified style (the 103 parameter). See this link for more details.

    Change this:

    dbo.refPasPatientRec1Master.Date_of_Birth AS Dob
    

    To:

    CONVERT(NVARCHAR(10), dbo.refPasPatientRec1Master.Date_of_Birth, 103) AS Dob
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm fairly new to C so sorry if this is a stupid question but
Really stupid question, sorry, but I can't find it on google (I'm sure it's
Firstly I asked sorry if this is a stupid question. but I have a
I'm really sorry. This must seem like an incredibly stupid question, but unless I
im sorry if this is a stupid question but i was curious, i have
Sorry if this is a stupid question but I am new to WP7 development
Sorry if this is a stupid question but new to this so need some
Sorry if it's a stupid question but i really can't find a answer :)
I'm sorry if this a stupid question, but I am new to this. I
Sorry, this is probably a really stupid question, but is it safe to run

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.