Solved

Creating a new column as a part of a stored proceedure

Posted on 2012-04-10
2
166 Views
Last Modified: 2012-04-10
Good Morning experts,

I am new to stored procedures but have worked with views for some time.  I am being asked to provide data in a stored procedure as apposed to a view and while I can work out how to provide the actual data from the database I'm also being asked to include a flag as to the type of record.  The stored procedure has all the needed data including a "ChannelAlias" if that column = "Bank" they want me to flag the record as "HomeEquity" if it is anything else they want me to flag the record as "Mortgage".  How do I do this? I've attached my stored procedure as well.  spScorecardData.docx
0
Comment
Question by:ISBTECH
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 20

Accepted Solution

by:
Daniel Van Der Werken earned 500 total points
ID: 37828624
You can select anything by just doing something like this:

SELECT '1' AS One,
            '2' AS Two

Etc. Therefore, we just create a new column out of thin air using the CASE statement. I have not validated this, but this statement should be exactly what you need if not very close to it:

   SELECT
"CB_Loan_View"."applicationdate",
"CB_Loan_View"."totalloanamount",
"CB_Loan_View"."loanid",
"CB_Borrower_View"."lastname",
"CB_Borrower_View"."firstname",
"CB_Loan_View"."statusdescription",
"CB_Loan_View"."statusalias",
"CB_Loan_View"."ltv",
"CB_Loan_View"."discountpoints",
"CB_Loan_View"."originationpoints",
"CB_Loan_View"."loanrate",
"CB_Loan_View"."productalias",
"CB_Loan_View"."loanrecordid",
"CB_Loan_View"."productdescription",
"CB_Loan_View"."actualclosingdate",
"CB_Loan_View"."statusorder", "
"CB_Loan_View"."channelalias",
"ISB_RefferalView"."Lead",
"ISB_RefferalView"."alias",
CASE WHEN "CB_Loan_View"."channelalias" = ‘Bank '
       THEN ‘HomeEquity’
       ELSE ‘Mortgate’ END AS "TypeOfRecord”
0
 

Author Closing Comment

by:ISBTECH
ID: 37828757
Perfect, Thanks!
0

Featured Post

Major Incident Management Communications

Major incidents and IT service outages cost companies millions. Often the solution to minimizing damage is automated communication. Find out more in our Major Incident Management Communications infographic.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question