Solved

Creating a new column as a part of a stored proceedure

Posted on 2012-04-10
2
167 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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

A Stored Procedure in Microsoft SQL Server is a powerful feature that it can be used to execute the Data Manipulation Language (DML) or Data Definition Language (DDL). Depending on business requirements, a single Stored Procedure can return differe…
What if you have to shut down the entire Citrix infrastructure for hardware maintenance, software upgrades or "the unknown"? I developed this plan for "the unknown" and hope that it helps you as well. This article explains how to properly shut down …
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function

623 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