Solved

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

Posted on 2014-02-05
9
1,130 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
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.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

919 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

14 Experts available now in Live!

Get 1:1 Help Now