I did look into that. Here is my attempt:
CREATE FUNCTION dbo.udf_ReportMaster (@Filters varchar(4000), @Company int, @User int)
RETURNS @ReportMaster TABLE ([ImprovementID] [bigint] NOT NULL, [MU_Employee_DepartmentID] [bigint] NOT NULL,
....... [ReminderDate] [smalldatetime] NULL) AS
BEGIN...
First thought, yes I need every single column as the various filters and reports that use this system are varied and wide, using every single column in the Improvement table. As new columns are added, new reports and filters are often added too!
Second thought, I hoped no one would say that...
This one's been bugging me all night.
OK, at present this is what I do.
I have a stored procedure (usp_ReportMaster) which returns the result of a dynamic SQL query like this:
SELECT Improvement.* FROM ..........
I then have many other stored procedures that run the above stored proc first and...
Thanks mate, worked a treat. I just got stuck in my thinking of trying to use DISTINCT (which I don't think would have worked). So easy when new eyes look at the problem!!
Scaled down table structure:
TblCustomer:
CustomerID
FirstName
Surname
etc
TblEnquiry:
EnquiryID
CustomerID
Source
etc
I am trying (as part of a larger query) to get a list of the EnquiryIDs for a customer's most recent enquiry (therefore the list will only have 1 entry for each customer...
I have been given a solution already:- Alias the table name. Thanks guys
FYI
Select m.Match_date, t1.Teamname, t2.Teamname from team t1, team t2, match m where m.HomeTeamID = t1.TeamID and m.AwayTeamID = t2.teamID
Cheers mate,
I never knew you could create aliases for table names (or whatever you call it). I've had that problem before and side stepped the issue with 2 queries (crap I know!!).
Ingenius (or maybe I should just learn SQL properly!)
ChoPa
Dear people,
I am tearing my hair out trying to write an SQL statement to do the following:
In Table "Team" amongst other things I have a "TeamID" and a "TeamName". In Table "Match" amongst other things I have a "HomeTeamID" and an...
Dear people,
I am tearing my hair out trying to write an SQL statement to do the following:
In Table "Team" amongst other things I have a "TeamID" and a "TeamName". In Table "Match" amongst other things I have a "HomeTeamID" and an...
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.