Solved

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

Posted on 2014-02-05
9
1,143 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
VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

 

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

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

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

Suggested Solutions

If you find yourself in this situation “I have used SELECT DISTINCT but I’m getting duplicates” then I'm sorry to say you are using the wrong SQL technique as it only does one thing which is: produces whole rows that are unique. If the results you a…
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 Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

777 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