Solved

Create Stored Procedure from a table and add an extra column using join

Posted on 2014-02-05
9
1,154 Views
Last Modified: 2014-02-13
I have a table. I want to develop a report that requires an additional column in that table. The additional column comes from another table.
I am planning to create a stored procedure from that original table and then to add an extra column from the other table using join.
To be informed that the data is updated regularly so I cannot use SELECT INTO kind of query.
How can I do this?
Does any one have idea or better suggestion to accomplish this?
Thanks in advance.
0
Comment
Question by:fireblues
  • 4
  • 2
9 Comments
 
LVL 24

Expert Comment

by:chaau
ID: 39837871
in SQL Server you can make stored procedures act like Select statements. These stored procedures can be used when building reports. All you need to do is to make the last statement of the stored procedure the SELECT statement you wish to be used as your report. Like this:
CREATE PROCEDURE uspGetAllEmployees
AS
    SET NOCOUNT ON;
    SELECT e.LastName, e.FirstName, h.Department
    FROM vEmployeeDepartmentHistory h INNER JOIN Employee e ON e.EmployeeID = h.EmployeeID;
GO

Open in new window

0
 
LVL 37

Accepted Solution

by:
ValentinoV earned 350 total points
ID: 39838101
It appears you are new to using stored procs in combination with SSRS.  The following article should shed some light on how to achieve this and should also contain some other useful info: Reporting On Data From Stored Procedures (part 1)

Don't hesitate to ask additional questions if still in doubt about something.
0
 

Author Comment

by:fireblues
ID: 39854353
Thanks for guiding me the way for the solution.
0
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 

Author Comment

by:fireblues
ID: 39855421
I've requested that this question be closed as follows:

Accepted answer: 0 points for fireblues's comment #a39854353

for the following reason:

I solved it using different way.
0
 
LVL 37

Expert Comment

by:ValentinoV
ID: 39855422
In comment #a39854353 you stated the following: "Thanks for guiding me the way for the solution."  That's a strong indication that the earlier posts have helped you to get to your solution, even if you "solved it using different way".  So those posts should get accepted as solution, not your own comment.  For that reason I'll object once more... (previous objection was because you closed with a C-grade without any further interaction with us, read through the links posted by Netminder to get an understanding why that's not a good idea)
0
 

Author Comment

by:fireblues
ID: 39857493
Since, I am new to this portal, I didn't know about the grades A, B and C.
Now that I have read, I know what they mean.
My apologies.
Of course the link helped me to go in certain direction.
I'll definitely reward points for that. :)
0
 

Author Closing Comment

by:fireblues
ID: 39857498
Thanks.
0

Featured Post

Webinar: Aligning, Automating, Winning

Join Dan Russo, Senior Manager of Operations Intelligence, for an in-depth discussion on how Dealertrack, leading provider of integrated digital solutions for the automotive industry, transformed their DevOps processes to increase collaboration and move with greater velocity.

Question has a verified solution.

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

It is helpful to note: This is a cosmetic update and is not required, but should help your reports look better for your boss.  This issue has manifested itself in SSRS version 3.0 is where I have seen this behavior in.  And this behavior is only see…
This article describes how to use the timestamp of existing data in a database to allow Tableau to calculate the prior work day instead of relying on case statements or if statements to calculate the days of the week.
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

828 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