Showing posts with label returned. Show all posts
Showing posts with label returned. Show all posts

Wednesday, March 21, 2012

Excluding part of select statement if no data is returned in results

I have a query that returns results based on information in several tables. The problem I am having is that is there are no records in the one table it doesn't return any information at all. This table may not have any information initially for the employees so I need to show results whether or not there is anything in this one table.

Here is my select statement:

SELECT employee.emp_id,DATEDIFF(mm, employee.emp_begin_accrual,GETDATE()) * employee.emp_accrual_rate - (SELECTSUM(request_duration)AS daystakenFROM request)AS daysleft, employee.emp_lname +', ' + employee.emp_fname +' ' + employee.emp_minitial +'.'AS emp_name, department.department_name, location.location_nameFROM employeeINNERJOIN requestAS request_1ON employee.emp_id = request_1.emp_idINNERJOIN departmentON employee.emp_department = department.department_idINNERJOIN locationON department.department_location = location.location_idGROUP BY employee.emp_id, employee.emp_begin_accrual, employee.emp_accrual_rate, employee.emp_fname, employee.emp_minitial, employee.emp_lname, department.department_name, location.location_nameORDER BY location.location_name, department.department_name, employee.emp_lname

The section below is the part that may or may not contain information:

SELECT (SELECTSUM(request_duration)AS daystakenFROM request)AS daysleft

So I need it to return results whether this sub query has results or not. Any help would be greatly appreciated!!!

TIA

BUMP... Somebody...|||

Okay, I tried adding the ISNULL to the statement, but I think the problem is because until a request has been put in there is nothing linking the employee table for the JOIN on the request table. When they put in a request it adds an entry to the request table for them. Up till that point, there will be nothing matching the two tables.

Here is my statement as it stands now. Is there anyway to get the results to show if the INNERJOIN isn't finding any results in the request table?

SELECT employee.emp_id,DATEDIFF(mm, employee.emp_begin_accrual,GETDATE()) * employee.emp_accrual_rate - (SELECTSUM(ISNULL(request_duration,'0'))AS daystakenFROM request)AS daysleft, employee.emp_lname +', ' + employee.emp_fname +' ' + employee.emp_minitial +'.'AS emp_name, department.department_name, location.location_nameFROM employeeINNERJOIN requestAS request_1ON employee.emp_id = request_1.emp_idINNERJOIN departmentON employee.emp_department = department.department_idINNERJOIN locationON department.department_location = location.location_idGROUP BY employee.emp_id, employee.emp_begin_accrual, employee.emp_accrual_rate, employee.emp_fname, employee.emp_minitial, employee.emp_lname, department.department_name, location.location_nameORDER BY location.location_name, department.department_name, employee.emp_lname

I know it seems I am just talking to myself at this point, but I would LOVE for someone to join my conversation. Thanks in advance for any help!!!

Wink

|||

Okay, I figured it out. Had to switch my query to a LEFT OUTER JOIN.

SELECT employee.emp_id,DATEDIFF(mm, employee.emp_begin_accrual,GETDATE()) * employee.emp_accrual_rate - (SELECTSUM(ISNULL(request_duration,'0'))AS daystakenFROM request)AS daysleft, employee.emp_lname +', ' + employee.emp_fname +' ' + employee.emp_minitial +'.'AS emp_name, department.department_name, location.location_nameFROM employeeLEFTOUTER JOIN requestAS request_1ON employee.emp_id = request_1.emp_idINNERJOIN departmentON employee.emp_department = department.department_idINNERJOIN locationON department.department_location = location.location_idGROUP BY employee.emp_id, employee.emp_begin_accrual, employee.emp_accrual_rate, employee.emp_fname, employee.emp_minitial, employee.emp_lname, department.department_name, location.location_nameORDER BY location.location_name, department.department_name, employee.emp_lname

Monday, March 12, 2012

Excessive memory usage

Hi.
my sqlservers are using 1.5 gigs of memory and
experiencing slow queries where large amount of rows are
returned. Some page swapping at the os is occurring as
well. Any ideas?Hi -
Please check the KB Arcticle
http://support.microsoft.com/default.aspx?scid=kb;EN-US;110983
Some time when any relatively heavy query/process comes down... the system
starts paging because there are not enough free sectors to swap out data
Thanks
-Surajit
"KD" <anonymous@.discussions.microsoft.com> wrote in message
news:19ae701c44d63$7558ee40$a401280a@.phx.gbl...
> Hi.
> my sqlservers are using 1.5 gigs of memory and
> experiencing slow queries where large amount of rows are
> returned. Some page swapping at the os is occurring as
> well. Any ideas?

Wednesday, March 7, 2012

Exception returned from reporting servicing

Hi, I'm got this unhandled exeption return from our reporting server and I don't know what it means or how I can ensure it doesn't happen again. We are using SQL Server 2005 and Reporting Services 2005 with .Net 2.0 (VS 2005) ASP.NET

any help appreciated

regards


Satvinder

Exception information: Exception typeTongue TiedoapException

Exception message: System.Web.Services.Protocols.SoapException: Execution 'l53cr2bl5ces523lsvet0s2y'
cannot be found > Microsoft.ReportingServices.Diagnostics.Utilities.ExecutionNotFoundException: Execution
'l53cr2bl5ces523lsvet0s2y' cannot be found
End of inner exception stack trace

at Microsoft.ReportingServices.WebServer.ReportExecutionService.GetExecutionInfo(ExecutionInfo_executionInfo)
Request information: Request URL: http://uat-WebSite/Reserved.ReportViewerWebControl.axd?ReportSession=l53cr2bl5ces523lsvet0s2y_ControlID=90412828-217e-4c47-a8b4-445adb99cf71_Culture=2057_UICulture=1033_ReportStack=1_OpType=SessionKeepAlive_Interval=454000

Request path: /Reserved.ReportViewerWebControl.axd User host address: 10.110.125.68
User: LONDON_UAT_SONASA Is authenticated: True Authentication Type: NTLM Thread
account name: LONDON_UAT Thread information: Thread ID: 10 Thread account
name: LONDON_UAT Is impersonating: False

Stack trace: at System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage
message, WebResponse response, Stream responseStream, Boolean asyncCall)
at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters)
at Microsoft.SqlServer.ReportingServices2005.Execution.ReportExecutionService.GetExecutionInfo()
at Microsoft.SqlServer.ReportingServices2005.Execution.RSExecutionConnection.GetExecutionInfo()
at Microsoft.Reporting.WebForms.ServerReport.TouchSession()
at Microsoft.Reporting.WebForms.SessionKeepAliveOperation.PerformOperation(NameValueCollection
urlQuery, HttpResponse response)
at Microsoft.Reporting.WebForms.HttpHandler.ProcessRequest(HttpContext context)
at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean_ completedSynchronously)

Custom event details: "
App: E 'Mon Jun 04 16:58:34 2007': LONDONWEB - " An internal error occurred on the report server. See the
error log for more details. (rsInternalError) "
App: E 'Mon Jun 04 16:58:34 2007': LONDONWEB - " An internal error occurred on the report server. See the
error log for more details. (rsInternalError) "
Sys: E 'Mon Jun 04 16:58:37 2007': DCOM - " The application-specific permission settings do not grant
Local Activation permission for the COM Server application with CLSID {BA126AD1-2166-11D1-B1D0-00805FC1270E}
to the user LONDON_ABC_PROD_UAT SID (S-1-5-21-388395589-1927312763-1538882281-22140). This security
permission can be modified using the Component Services administrative tool. "

I'm not sure, but it could have something to do with the fact that in some cases when executing a report, the URL can contain an execution ID. The execution is specific to the session and user running the report. When the session times out, or the URL is copied or used by someone else, errors may appear indication that the execution is not valid.

The URL in the error message contains a Execution ID and so this URL is only valid for some time and only for the user who started the report.

Regards, Jeroen