Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Stored procedure to join two table. Expand / Collapse
Author
Message
Posted Thursday, April 3, 2014 8:02 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Thursday, April 3, 2014 9:09 AM
Points: 2, Visits: 3
I want to write fetch data through stored procedure where we have to join two table. for example in i want to write this query in stored procedure
SELECT myReport_1.id AS [ID]
,myReport_1.r_id AS [Report ID]
,login.Name, CONVERT(VARCHAR,myReport_1.date,106) AS Date
,myReport_1.job_name AS [Job Name]
,myReport_1.job_status AS Status
,myReport_1.Quantity
,myReport_1.Tot_time AS [Total Time Taken]
,myReport_1.center AS [Center Code]
FROM
login INNER JOIN myReport AS myReport_1 ON login.id = myReport_1.id


please suggest me
Post #1557991
Posted Thursday, April 3, 2014 8:25 AM


SSC-Insane

SSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-Insane

Group: General Forum Members
Last Login: Yesterday @ 9:44 PM
Points: 21,187, Visits: 14,879
Without table definitions and without sample data, all we could do is say the query you provided should do the trick.



Jason AKA CirqueDeSQLeil
I have given a name to my pain...
MCM SQL Server


SQL RNNR

Posting Performance Based Questions - Gail Shaw
Posting Data Etiquette - Jeff Moden
Hidden RBAR - Jeff Moden
VLFs and the Tran Log - Kimberly Tripp
Post #1558009
Posted Thursday, April 3, 2014 9:00 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Thursday, April 3, 2014 9:09 AM
Points: 2, Visits: 3
should i have to send the schema of my both table ???
Post #1558032
Posted Thursday, April 3, 2014 9:24 AM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Yesterday @ 2:57 PM
Points: 13,058, Visits: 11,884
fatmazarin07 (4/3/2014)
should i have to send the schema of my both table ???


What is your actual question here?

Assuming the code you posted in your original post is what you want from your stored procedure then what you posted will work fine.


_______________________________________________________________

Need help? Help us help you.

Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.

Need to split a string? Try Jeff Moden's splitter.

Cross Tabs and Pivots, Part 1 – Converting Rows to Columns
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs
Understanding and Using APPLY (Part 1)
Understanding and Using APPLY (Part 2)
Post #1558048
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse