Solved

Creating a new column as a part of a stored proceedure

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

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

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

Suggested Solutions

Nowadays, some of developer are too much worried about data. Who is using data, who is updating it etc. etc. Because, data is more costlier in term of money and information. So security of data is focusing concern in days. Lets' understand the Au…
When you hear the word proxy, you may become apprehensive. This article will help you to understand Proxy and when it is useful. Let's talk Proxy for SQL Server. (Not in terms of Internet access.) Typically, you'll run into this type of problem w…
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.

803 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