Showing posts with label fit. Show all posts
Showing posts with label fit. Show all posts

Friday, March 30, 2012

Having trouble getting SP from sql Server 2005 to work in SQL Server 2000

I am getting an error saying incorrect syntax near f

It works in SQL Server 2005, but I cannot get it to work in SQL Server 2000

The error appears to be in the section that I marked in Bold.

CREATE PROCEDURE [dbo].[pe_getReport]
-- Add the parameters for the stored procedure here
@.BranchID INT,
@.InvestorID INT,
@.Status INT,
@.QCAssigned INT,
@.LoanOfficer nvarChar(40),
@.FromCloseDate DateTime,
@.ToCloseDate DateTime,
@.OrderBy nvarChar(50)
AS
DECLARE
@.l_Sql NVarChar(4000),
@.l_OrderBy NVarChar(500),
@.l_OrderCol NVarChar(150),
@.l_CountSql NVarChar(4000),
@.l_Where NVarChar(4000),
@.l_SortDir nvarChar(4)

BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;

SET @.l_Where = N' Where 1=1'

IF (@.BranchID IS NOT NULL)
SET @.l_Where = @.l_Where + N' AND f.BranchID=' + CAST(@.BranchID As NVarChar)

IF (@.Status IS NOT NULL)
SET @.l_Where = @.l_Where + N' AND f.Status=' + CAST(@.Status As NVarChar)

IF (@.InvestorID IS NOT NULL)
SET @.l_Where = @.l_Where + N' AND f.InvestorID=' + CAST(@.InvestorID As NVarChar)

IF (@.QCAssigned IS NOT NULL)
SET @.l_Where = @.l_Where + N' AND f.QCAssigned=' + CAST(@.QCAssigned As NVarChar)

IF (@.LoanOfficer IS NOT NULL)
SET @.l_Where = @.l_Where + N' AND f.LoanOfficer LIKE ''' + @.LoanOfficer + '%'''

IF (@.FromCloseDate IS NOT NULL)
SET @.l_Where = @.l_Where + N' AND f.ClosingDate>=''' + CAST(@.FromCloseDate AS NVarChar) + ''''

IF (@.ToCloseDate IS NOT NULL)
SET @.l_Where = @.l_Where + N' AND f.ClosingDate<=''' + CAST(@.ToCloseDate AS NVarChar) + ''''

IF @.OrderBy IS NULL
SET @.OrderBy = 'DateEntered DESC'

SET @.l_SortDir = SUBSTRING(@.OrderBy, CHARINDEX(' ', @.OrderBy) + 1, LEN(@.OrderBy))
SET @.l_OrderCol = SUBSTRING(@.OrderBy, 1, NULLIF(CHARINDEX(' ', @.OrderBy) - 1, -1))
IF @.l_OrderCol = 'InvestorName'
SET @.l_OrderBy = 'i.InvestorName ' + @.l_SortDir
ELSE IF @.l_OrderCol = 'BName'
SET @.l_OrderBy = 'b.BName ' + @.l_SortDir
ELSE IF @.l_OrderCol = 'StatusDesc'
SET @.l_OrderBy = 's.StatusDesc ' + @.l_SortDir
ELSE IF @.l_OrderCol = 'QCAssigned'
SET @.l_OrderBy = 'q.LoginName ' + @.l_SortDir
ELSE SET @.l_OrderBy = 'f.' + @.l_OrderCol + ' ' + @.l_SortDir

SET @.l_CountSql = 'SELECT f.FundedID As FundedID FROM FundedInfo AS f LEFT OUTER JOIN
Investors AS i ON f.InvestorID = i.InvestorID LEFT OUTER JOIN
Branches AS b ON f.BranchID = b.BranchID LEFT OUTER JOIN
Status AS s ON f.Status = s.StatusID LEFT OUTER JOIN
QCLogins AS q f.QCAssigned = q.LoginID '
+ @.l_Where + ' ORDER BY ' + @.l_OrderBy

CREATE TABLE #RsltTable (ID int IDENTITY PRIMARY KEY, FundedID int)
INSERT INTO #RsltTable(FundedID)
EXECUTE (@.l_CountSql)

SELECT f.DateEntered As DateEntered, f.LastName As LastName, f.LoanNumber As LoanNumber,
f.LoanOfficer As LoanOfficer, f.ClosingDate As ClosingDate,
i.InvestorName As InvestorName, b.BName As BName, s.StatusDesc As StatusDesc,
q.LoginName As LoginName
FROM
FundedInfo AS f LEFT OUTER JOIN
Investors AS i ON f.InvestorID = i.InvestorID LEFT OUTER JOIN
Branches AS b ON f.BranchID = b.BranchID LEFT OUTER JOIN
Status AS s ON f.Status = s.StatusID LEFT OUTER JOIN
QCLogins As q ON f.QCAssigned = q.LoginID
WHERE FundedID IN(SELECT FundedID FROM #rsltTable)
ORDER BY
CASE @.OrderBy WHEN 'DateEntered ASC' THEN f.DateEntered END ASC,
CASE @.OrderBy WHEN 'DateEntered DESC' THEN f.DateEntered END DESC,
CASE @.OrderBy WHEN 'LastName ASC' THEN f.LastName END ASC,
CASE @.OrderBy WHEN 'LastName DESC' THEN f.LastName END DESC,
CASE @.OrderBy WHEN 'LoanNumber ASC' THEN f.LoanNumber END ASC,
CASE @.OrderBy WHEN 'LoanNumber DESC' THEN f.LoanNumber END DESC,
CASE @.OrderBy WHEN 'LoanOfficer ASC' THEN f.LoanOfficer END ASC,
CASE @.OrderBy WHEN 'LoanOfficer DESC' THEN f.LoanOfficer END DESC,
CASE @.OrderBy WHEN 'ClosingDate ASC' THEN f.ClosingDate END ASC,
CASE @.OrderBy WHEN 'ClosingDate DESC' THEN f.ClosingDate END DESC,
CASE @.OrderBy WHEN 'InvestorName ASC' THEN i.InvestorName END ASC,
CASE @.OrderBy WHEN 'InvestorName DESC' THEN i.InvestorName END DESC,
CASE @.OrderBy WHEN 'BName ASC' THEN b.BName END ASC,
CASE @.OrderBy WHEN 'BName DESC' THEN b.BName END DESC,
CASE @.OrderBy WHEN 'StatusDesc ASC' THEN s.StatusDesc END ASC,
CASE @.OrderBy WHEN 'StatusDesc DESC' THEN s.StatusDesc END DESC,
CASE @.OrderBy WHEN 'LoginName ASC' THEN q.LoginName END ASC,
CASE @.OrderBy WHEN 'LoginName DESC' THEN q.LoginName END DESC
END
GO

Do a PRINT @.l_CountSql before you EXEC the SQL. That can help you debug the SQL Statement that is being formed.|||Thanks, I am blind... I was missing the 'ON' in the last LEFT OUTER JOIN

Friday, March 23, 2012

Have Subreport NOT Keep Together

I have a subreport inside a table on the main report. It seems
everything I
try the subreport will keep together on a new page if it cannot fit
itself
on the rest of the first page. How can I have the subreport display
it's
data on the rest of the first page and continue on to the second page?
I have looked at everything I can think of. Keep Together is set to
false
everywhere.
Please help.
Thanks,Same thing here !
We have reports with 2-3 levels of subreports and the data "migrates"
sometimes to the 4th page, leaving the first 2-3 pages just with a small
header on top... it's very difficult to explain to a client why their report
looks like that. And this problem is active since the beginning of reporting
services. A few service packs later, a new version, and it's still out
there...
For some of the reports we managed to eliminate the subreports, but just
imagine how the datasets look like in the main report :(
Or, we transferred the burden of "subreporting" to the processing part,
creating a separate table to keep all the pre-calculated data, with headers
and subreport information, etc., leaving to Reporting Services the only task
of displaying the content of the table. But it's much more difficult and it
lacks flexibility !
Please, if anyone has a solution to this, make it public !
We regularly search the newsgroups for a solution to this problem, but
untill now, we just noticed a lot of people having this problem...
Thank you,
Andrei.
<sjackson@.nexterna.com> wrote in message
news:1168641290.758091.292180@.m58g2000cwm.googlegroups.com...
>I have a subreport inside a table on the main report. It seems
> everything I
> try the subreport will keep together on a new page if it cannot fit
> itself
> on the rest of the first page. How can I have the subreport display
> it's
> data on the rest of the first page and continue on to the second page?
> I have looked at everything I can think of. Keep Together is set to
> false
> everywhere.
> Please help.
> Thanks,
>|||The sad thing is that I heard it is an issue that Microsoft has added
to their wish list. So you really need to limit the use of sub reports
or you can run into this issue.
Hopefully they can expedite the resolution of this issue.
Andrei wrote:
> Same thing here !
> We have reports with 2-3 levels of subreports and the data "migrates"
> sometimes to the 4th page, leaving the first 2-3 pages just with a small
> header on top... it's very difficult to explain to a client why their report
> looks like that. And this problem is active since the beginning of reporting
> services. A few service packs later, a new version, and it's still out
> there...
> For some of the reports we managed to eliminate the subreports, but just
> imagine how the datasets look like in the main report :(
> Or, we transferred the burden of "subreporting" to the processing part,
> creating a separate table to keep all the pre-calculated data, with headers
> and subreport information, etc., leaving to Reporting Services the only task
> of displaying the content of the table. But it's much more difficult and it
> lacks flexibility !
> Please, if anyone has a solution to this, make it public !
> We regularly search the newsgroups for a solution to this problem, but
> untill now, we just noticed a lot of people having this problem...
> Thank you,
> Andrei.
>
>
> <sjackson@.nexterna.com> wrote in message
> news:1168641290.758091.292180@.m58g2000cwm.googlegroups.com...
> >I have a subreport inside a table on the main report. It seems
> > everything I
> > try the subreport will keep together on a new page if it cannot fit
> > itself
> > on the rest of the first page. How can I have the subreport display
> > it's
> > data on the rest of the first page and continue on to the second page?
> >
> > I have looked at everything I can think of. Keep Together is set to
> > false
> > everywhere.
> >
> > Please help.
> >
> > Thanks,
> >|||Will someone from Microsoft please address this question? This is a very
basic reporting need. Is a service pack in the works?|||"sjackson@.nexterna.com" wrote:
> I have a subreport inside a table on the main report. It seems
> everything I
> try the subreport will keep together on a new page if it cannot fit
> itself
> on the rest of the first page. How can I have the subreport display
> it's
> data on the rest of the first page and continue on to the second page?
> I have looked at everything I can think of. Keep Together is set to
> false
> everywhere.
> Please help.
> Thanks,
>|||I have the same problem.
I find many posts related to this problem and recentily I published my own
post with several links to other posts, but yet any answer from MS.
Here is my post
http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1279676&SiteID=1
"sjackson@.nexterna.com" wrote:
> I have a subreport inside a table on the main report. It seems
> everything I
> try the subreport will keep together on a new page if it cannot fit
> itself
> on the rest of the first page. How can I have the subreport display
> it's
> data on the rest of the first page and continue on to the second page?
> I have looked at everything I can think of. Keep Together is set to
> false
> everywhere.
> Please help.
> Thanks,
>|||Did anybody find a solution to this problem ?
Maybe somebody from Microsoft can be of assistance ?
<sjackson@.nexterna.com> wrote in message
news:1168641290.758091.292180@.m58g2000cwm.googlegroups.com...
>I have a subreport inside a table on the main report. It seems
> everything I
> try the subreport will keep together on a new page if it cannot fit
> itself
> on the rest of the first page. How can I have the subreport display
> it's
> data on the rest of the first page and continue on to the second page?
> I have looked at everything I can think of. Keep Together is set to
> false
> everywhere.
> Please help.
> Thanks,
>|||Also wrestling with this one. Also irritated by the "No fields in headers or
footers thing" but got that working.
I am now at the point where I am possibly going to play with the byte stream
output by Localreport.Render("PDF"...) to try and make it work the way I
want. Fortunately only PDF is reuired.
Will come back to this post if I find something...
--
Programming is fun but paralgiding is better!|||Same thing here as well sjackson. No one has any answers? Let's add another
client to the 'I'm Not impressed with that SQL Reporting service thing mister
contractor' list.
"sjackson@.nexterna.com" wrote:
> I have a subreport inside a table on the main report. It seems
> everything I
> try the subreport will keep together on a new page if it cannot fit
> itself
> on the rest of the first page. How can I have the subreport display
> it's
> data on the rest of the first page and continue on to the second page?
> I have looked at everything I can think of. Keep Together is set to
> false
> everywhere.
> Please help.
> Thanks,
>