Solved

Creating a new column as a part of a stored proceedure

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

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Scheduled IIS .Net2 AppPools recycle and SQL connection Hangs 33 86
SPROC to look for existing record in passed table name 7 46
SQL 2008 SSIS import 11 50
ASP.NET 5 Templates 2 65
Everyone has problem when going to load data into Data warehouse (EDW). They all need to confirm that data quality is good but they don't no how to proceed. Microsoft has provided new task within SSIS 2008 called "Data Profiler Task". It solve th…
JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.

932 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

9 Experts available now in Live!

Get 1:1 Help Now