Viewing 15 posts - 826 through 840 (of 1,246 total)
Anandkumar-SQL_Developer (9/16/2016)
select [KPI ID]
,[KPI Name],
[KPIFormula] = case when [kpi id] = 'SA2' then '[QW1]+[SA2]+[BG7]'
when [kpi id] = 'XS3' then '[QW1]+[BG7]'
when [kpi id] = 'BG7' then 'BG7' else [kpi id]end
...
September 16, 2016 at 9:46 am
ken.trock (9/15/2016)
CREATE TABLE dbo.EmployeeHistory (StartDate SMALLDATETIME, EndDate SMALLDATETIME, NativeWorkerID VARCHAR(255), EmployeeID VARCHAR(20))
CREATE TABLE dbo.EH_NativeWorker_Dups(NativeWorkedID VARCHAR(255))
SELECT DISTINCT EmployeeID, NativeWorkerID...
September 15, 2016 at 8:23 pm
The Dixie Flatline (9/15/2016)
I don't think I've ever done a RIGHT JOIN in production. :ermm:
Ditto... Keep the "left table" to the left...
September 15, 2016 at 11:58 am
Here's another good way to handle massive deletes... No down time for the affected table and works especially well if the table is schema-bound by another object...
Partition SWITCH...
USE tempdb;
GO
--================================================================
--...
September 15, 2016 at 11:07 am
j-1064772 (9/14/2016)
tripleAxe (9/14/2016)
How about this.....
SELECT 'AZ' [STATE], SUM(AZ) [VAL] FROM EXAMPLE
UNION ALL
SELECT 'NY' [STATE], SUM(NY) [VAL] FROM EXAMPLE
UNION ALL
SELECT 'PA' [STATE], SUM(PA) [VAL] FROM EXAMPLE
Yes, this was my question from...
September 14, 2016 at 12:53 pm
tripleAxe (9/14/2016)
How about this.....
SELECT 'AZ' [STATE], SUM(AZ) [VAL] FROM EXAMPLE
UNION ALL
SELECT 'NY' [STATE], SUM(NY) [VAL] FROM EXAMPLE
UNION ALL
SELECT 'PA' [STATE], SUM(PA) [VAL] FROM EXAMPLE
That's going to do 3 separate pulls...
September 14, 2016 at 9:37 am
The Dixie Flatline (9/14/2016)
Is it just me, or is the syntax for PIVOT/UNPIVOT *much* harder to follow than cross-tab or APPLY VALUES ?
Agree 100%... PIVOT & UNPIVOT were solutions to...
September 14, 2016 at 9:33 am
Either way, yours is clearly better (well done sir!). Considering the sample size, I didn't bother looking the the timings. It's just not large enough to get accurate times and...
September 14, 2016 at 9:31 am
Looking at execution plans... Chris's script is far more efficient than mine... Use his script.
Just an FYI... Chris and I are using the same split function. We just gave them...
September 14, 2016 at 8:54 am
drew.allen (9/14/2016)
The phrase is "moot point".
Fixed. 😀
Just looking at the execution plans... Summing 1st is quite a bit more efficient...
IF OBJECT_ID('tempdb..#Example','U') IS NOT NULL
DROP TABLE #Example;
CREATE TABLE #Example (
id INT,
AZ...
September 14, 2016 at 8:42 am
This should do what you're asking...
-- Test data --
IF OBJECT_ID('tempdb..#OrigTable', 'U') IS NOT NULL
DROP TABLE #OrigTable;
CREATE TABLE #OrigTable (
KPI_ID CHAR(3),
KPI_NAME CHAR(3),
KPIFORMULA VARCHAR(1000)
);
INSERT #OrigTable (KPI_ID, KPI_NAME, KPIFORMULA) VALUES
('QW1', 'ABC', 'No...
September 14, 2016 at 8:16 am
Jeff Moden (9/14/2016)
September 14, 2016 at 6:46 am
If you'd like some help, take a look at the link in Drew's signature to see how to post so that you have the best chance of getting an answer.
September 13, 2016 at 9:49 pm
TheSQLGuru (9/13/2016)
CROSS APPLY VALUES #FTW!! Nicely done Jason. 🙂
TY Sir! 😀
September 13, 2016 at 8:09 pm
Viewing 15 posts - 826 through 840 (of 1,246 total)