SSRS HEADER CHANGE (Change column name) - sql-server

I have the following table in which I have already calculated the 95 percentile in SQL SERVER 2012.I want to produce the report in SSRS 2008R2. But when I place [95th%ile] in SSRS table column, it change the header to [ID95th ile]. Is there a way I can change it to [95th%ile] as this is what is in the current excel report and I have been told not to change it to any other name
Below is sample data that I am using.
CREATE TABLE ##PerCent (month Varchar(10), Percentile INT)
INSERT INTO ##PerCent
VALUES
('Jan',153),
('Feb',171),
('Mar',141)
SELECT
month,
Percentile AS '95th%ile'
FROM ##PerCent

You cannot add a field which name starts with numbers or any character different to a letter.
However you can change the name in the tablix header if you are presenting the dataset in that component.
Let me know if this helps.

Related

T-SQL MIN on Date type resulting in INT

I have a table with a column called ThisDayOfTherapy which is of datatype DATE in SQL Server.
Later, I have an aggregate query using Min(ThisDayOftherapy). This query populates a #temp table with the result of Min(ThisDayOfTherapy) as column name StartDate_Min
In a 3rd location I am finally doing something with StartDate_Min. When I hold my mouse over StartDate_Min, it says the datatype is INT.
Shouldn't it simply be DATE? Will it still work as if it were a date for all practical purposes?
I see the same behavior, but I think you will be fine. SQL Server would not execute any date functions if it was not a valid date. Adding one day to my MinDate column from my temp table is working as expected.

Automatically produce aliases for all columns in SELECT statement

I'm using Microsoft Query to pull data from MS SQL Server to Excel. Many of my tables have the same column names, for example:
[task].[active]
[user].[active]
[task].[name]
[user].[name]
When I pivot in Excel, only the column names are shown. A pivot filter might have multiple fields called "active" which is very confusing.
I'd like to alias every column with the table name it's from, so that in the filter it would say "task_active" and "user_active". My Excel SELECT statement would be:
SELECT active AS task_active, name AS task_name FROM task...
Is there a quick way to prepend the table name to an alias using a formatting tool? I have Apex SQL Refactor, and Notepad++ but I haven't found a way to do this without having to manually type all of the column names again.
If you populate resultset to datatable then datatable to excel then it will automatically change duplicate column name to col1,col2 etc.
This is not your requirement.you want it to be specific.
Method 1 . Create temp table with desire column name
Insert the result in #temp table
Return #temp table result set
Method 2 : Use dynamic query.
Wht your real query look like ?

How to check last accessed time about heap table (with no index)

I use SQL Server versions 2008, 2012, 2017.
I can check the last accessed time of a table if the table has indexes.
However if the table doesn't have any indexes, how can I check the last accessed time?
Is it possible with a query?
If the table in question has a column called eg. TxDate or any other name, you can run the following script to get your results:
select
max(TxDate) as [Date]
from ['Your Table']
Just customize the above script to the column name in your table.
Let me know if it works.

SQL Server: Get the last row entries (more than one) with sql query

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.

How to show data in column in SSRS

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:

Resources