I have table that stores about 250K rows of data. the select * query takes about 15 seconds to run in SSMS. Rendering the report in SSRS is not working. It just keep loading for about 5 minutes and sometimes works and other times out. Here's my two questions:
Is there a way to speed up the select query in SSMS?
Is there fix to the issue I'm having in SSRS?
I have tried converting the query into a stored procedure. Still the same problem in SSRS.
I have tried adding a new column to the table which assigns the same id for group of rows based on the date column. i.e. if the year of the date column is 2017 then all rows with this year will have id column = 1 and if it's 2018 then the id column = 2
I have tried limiting the number of rows in each page in SSRS but, still no luck.
Related
Scenario: a user will copy and paste data (multiple rows) from an Excel sheet onto my webpage and press submit. When this occurs, the data will be saved into a SQL Server table. The current date will also be saved next to each row.
Now, in another gridview, I would like to view only these multiple rows that have been pasted /saved to DB that certain day.
So I was thinking about using TOP / MAX(date) but Top returns specified rows only, and MAX only 1 row.
Anyone out there that has done this before or can help get a working query?
Use TOP WITH TIES in order to get all last entries:
SELECT TOP(1) WITH TIES
...
ORDER BY submit_date DESC;
Is "that certain day" based on a specific day or a 24 hour interval?
You can make the gridview query the data where the date field is higher than or equal to dateadd(dd, -1, getdate())
Or if you mean the current day as in the current date, where the date is equal to the date of getdate.
I have table with about 400 columns and 4 million rows in SQL Server 2012.
the only purpose of this table to be used by a reporting tool. this table is refreshed(dropped and recreated) every night via scheduled Job. so no update/insert/delete.
there is a Date column with Datetime as datatype. I have created a clustered index on this date column but it only seemed to help a little.(there wont be any other conditions on where clause so I haven't included any other columns in the index)
the query send by reporting tool is like
select *(all columns listed)
from mytable
where date>='01/01/2010' and date <='12/01/2010'
it takes about 10 mins to retrieve all that falls under above date range which is about a million rows.
I need to get this under a minute if I can or the best I can.
if I can get some idea that might help me to achieve this . I would greatly appreciate it.
I have tried following but no significant performance gain.
-change datatype to 'Date'/'varchar'/'int' from 'Datetime'
-create nonclustered index on same column
-create clustered/nonclustered index including other columns to make it unique
100 million rows may just plain be a data volume thing.
Try:
select count(*) from mytable where date>='01/01/2010' and date <='12/01/2010'
If that is fast then it is not an index issue
Relatively new to MDX but familiar with SSRS and I have a query that works just as I want it to in the query designer in SSMS however I'm not quite sure how to parameterize this in SSRS.
Query returns department and shift as dimensions and Hours and Period as Measures with the query being filtered by a fiscal year and the Period measure as a specific period for that year.
Query works as expected but do not know how to convert to SSRS by implementing parameters for Fiscal Period and Fiscal Year.
Query:
WITH MEMBER [measures].[Period] AS
SUM([Date].[Fiscal Period].[P9],[Measures].[Hours])
SELECT NON EMPTY [Department].[Department].[Department] * [Associate].[Current Shift].[Current Shift] on Rows,
{[Measures].[Hours], [Measures].[Period]} ON Columns
FROM Personnel
WHERE [Date].[Fiscal Year].[FY2015]
Create two parameters for Fiscal year and Fiscal Period. Then use the below query:
SELECT NON EMPTY [Department].[Department].[Department] * [Associate].[Current Shift].[Current Shift] on Rows,
[Measures].[Hours] ON Columns
FROM Personnel
WHERE
(
StrToMember(#FiscalYear, CONSTRAINED),
StrToMember(#FiscalPeriod, CONSTRAINED)
)
I'm using SSRS for my reporting, my reporting solution is in Visual Studio 2008 Business Intelligence Development Studio.
I have a report in which the data should be displayed in this format.
I have added a Column Group in my table which is having the values of Customer Name and details, the data is coming fine in the vertical format i.e column after column.
My Issue :
There should be only three columns in each row, after three records the next row should begin and again not more than three records should be displayed as shown in the image above.
My attempts :
I tried to add a row group and in that gave the expression
= Ceiling(Fields!Row_Count.Value/3)
here Row_Count is a field which is coming from my query which holds the serial number of the records.
My SQl Query
SELECT Row_Number() over(order by table_ID) AS Row_Count, Field_1,Field_2 from MyTable
In my Column group i have Customer Name and in my Row Group i have other details of the customer. The data is getting populated column wise but the issue is its not breaking the current row after three records.
Below is my table of report.
You were on the right track. Say you have data like this:
I have created a tablix like this:
The Row Group expression is:
=Ceiling(Fields!Row_Count.Value / 3)
This works together with the Column Group expression to split over three columns:
=(Fields!Row_Count.Value - 1) Mod 3
The other thing to note compared to your tablix is that CustomerName is not in a table header row, but rather there are two row header rows, one for CustomerName and one for Details.
This is looking OK to me, obviously you can format to taste:
I'm writing a report in Crystal Reports XI Developer that runs a stored procedure in a SQL Server 2005 database. The record set returns a summary from log table grouped by Day and Hour.
Currently my query looks something like this:
SELECT
sum(colA) as "Total 1",
day(convert(smalldatetime, convert(float, Timestamp) / 1440 - 1)) as "Date",
datepart(hh, convert(smalldatetime, convert(float, Timestamp) / 1440 - 1)) as "Hour"
`etc...`
GROUP BY
Day, Hour
Ignore the date insanity, I think the system designers were drinking heavily when they worked out how to store their dates.
My problem is this: since there are not always records from each hour of the day, then I end up with gaps, which is understandable, but I'd like Crystal to be able to report on the entire 24 hours regardless of whether there is data or not.
I know I can change this by putting the entire query in a WHILE loop (within the stored procedure) and doing queries on the individual hours, but something inside me says that one query is better than 24.
I'd like to know if there's a way to have Crystal iterate through the hours of the day as opposed to iterating through the rows in the table as it normally does.
Alternatively, is there a way to format the query so that it includes the empty hour rows without killing my database server?
Here's how I solved this problem:
Create a local table in your SQL-Server. Call it "LU_Hours".
This table will have 1 integer field (called "Hours") with 24 rows. Of course, the values would be 1 through 24.
Right join this onto your existing query.
You might need to tweak this to make sure the nulls of empty hours are handled to your satisfaction.
You could use a WITH clause to create the 24 hours, then OUTER JOIN it.
WITH hours AS (
SELECT 1 AS hour
UNION
SELECT 2 AS hour
...
SELECT 24 AS hour
)
SELECT *
FROM hours h
LEFT OUTER JOIN [your table] x ON h.hour=x.datepart(hh, convert(smalldatetime, convert(float, Timestamp) / 1440 - 1))
This SQL would need to added to a Command.
Group as necessary in the SQL or the report.