Viewing 15 posts - 1 through 15 (of 84 total)
One way to approach this is to create the required detail and group levels individually, then union together and "order by" to get the results. Using CTEs keeps the individual...
January 3, 2018 at 8:20 am
Just to demonstrate a couple of possibilities. The first example doesn't show the actual dates in the column headers, only the day of week, but is very simple. The second...
April 23, 2017 at 11:02 pm
We have an Access Project (.adp) running on Access 2003 and have recently moved the database from SQL Server 2008 to 2014. Not recommending this platform, but have no budget...
April 23, 2017 at 8:59 pm
May not be the issue here, but in SSMS, if someone opens the view using <Right-Click> Design, opening the view in the Query Designer, and then saves it, the formating...
October 22, 2013 at 8:52 am
Using CTE's, the logic of certain queries can be broken down in to simpler steps:
[Code="sql"]
WITH pd(zParty_Code, zSumPaid_Amt)
AS (
SELECT party_code, SUM(paid_amt)
FROM dbo.tPartyData
WHERE paid_date < '11/27/2012'
...
September 23, 2013 at 8:09 am
Erland,
In case you didn't notice, I said the solution could be "something like." I was not offering a "production" solution. The original question was not specific enough. ...
September 13, 2013 at 7:14 am
If you are trying to make the column names and number of columns dynamic, you could try something like:
DECLARE @TempTableName AS NVARCHAR(128)
, @FirstColumnName AS...
September 12, 2013 at 8:50 am
ChrisCarsonSQL,
No disagreement. Point well taken...Thanks.
By the way, I recommend Erland Sommarskog's article: The Curse and Blessings of Dynamic SQL.
August 28, 2013 at 8:40 am
FYI
The referenced KB Article is about aggregate concatenation queries with an ORDER BY clause, as follows:
"You may encounter unexpected results when you apply any operators or expressions to the...
August 28, 2013 at 7:22 am
I would certainly validate the generated script before running it in either case.
August 26, 2013 at 7:47 am
A little easier to understand:
DECLARE @SQL NVARCHAR(MAX) ;
DECLARE @TableNameStartsWith AS NVARCHAR(50)= 'junk1'
SET @SQL = ''
SELECT @SQL = @SQL + ' Truncate table ' + QUOTENAME(TABLE_NAME) + '; ' + CHAR(13)
FROM...
August 26, 2013 at 7:30 am
Just a guess:
It look like the issue is related to the Finnish alphabet, which only uses the "W" for spelling on foreign words. Pure Finnish words apparently don't use...
August 22, 2013 at 3:10 pm
Not a proposed solution, but an example of using system views to create a dynamic SQL SELECT statement that is only executed once to generate the output.
/*
* Simple example...
August 15, 2013 at 10:28 am
Just for fun (and providing the Employee_ID is valid for determining First and Last), you could use Cross Apply to get the First and Last Record so that when the...
August 13, 2013 at 9:28 am
ChrisM@Work,
I meant it the exact way vega805 was trying to use it, which is the same way MS Access allows, and the exact way that SQL Server has never allowed.
Have...
August 1, 2013 at 7:51 am
Viewing 15 posts - 1 through 15 (of 84 total)