Solved

Creating a new column as a part of a stored proceedure

Posted on 2012-04-10
2
161 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
2 Comments
 
LVL 19

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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Introduction SQL Server Integration Services can read XML files, that’s known by every BI developer.  (If you didn’t, don’t worry, I’m aiming this article at newcomers as well.) But how far can you go?  When does the XML Source component become …
Introduction In my previous article (http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/SSIS/A_9150-Loading-XML-Using-SSIS.html) I showed you how the XML Source component can be used to load XML files into a SQL Server database, us…
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Via a live example, show how to shrink a transaction log file down to a reasonable size.

759 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now