Viewing 15 posts - 6,151 through 6,165 (of 10,143 total)
Welsh Corgi (6/29/2012)
After I got the record COUNT correct I was going to incorporate an INSERT INTO with CASE...
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
June 29, 2012 at 6:29 am
satishthota (6/29/2012)
I need a query without split function
What is the maximum number of discrete values to be found in the comma-delimited string?
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
June 29, 2012 at 6:26 am
SELECT Data
INTO #PIDs
FROM dbo.Split('101,103',',')
CREATE CLUSTERED INDEX [xyz] ON #PIDs (Data)
SELECT *
FROM dbo.Product_Test p
INNER JOIN #PIDs d ON d.Data = p.PID
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
June 29, 2012 at 6:21 am
Welsh Corgi (6/29/2012)
What is wrong with my statement and how can...
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
June 29, 2012 at 6:16 am
SQL Server will ignore both the TOP(100 percent) and the ORDER BY. You should reconsider what you are trying to do here.
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
June 29, 2012 at 4:44 am
_simon_ (6/29/2012)
@chrism-2@Work - that's it, thanks 🙂Is there any specific reason why you used dense_rank function? I tried with two row_number functions and it still works ok.
I'd be interested to...
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
June 29, 2012 at 3:03 am
This shouldn't be too difficult.
What does @PivotColumnHeaders look like?
Can you provide DDL for the two tables, with some sample data?
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
June 29, 2012 at 2:59 am
SELECT Username,
DateFrom = MIN([Date]),
DateTo = MAX([Date]),
CodeFrom = MIN(Code),
CodeTo = MAX(Code)
FROM (
SELECT Username, [Date], Code,
rn = ROW_NUMBER() OVER(ORDER BY Username, Code),
dr = DENSE_RANK() OVER(ORDER BY Code)
FROM @originalTable
)...
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
June 29, 2012 at 2:34 am
dwain.c (6/28/2012)
Jeff Moden (6/28/2012)
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
June 29, 2012 at 2:15 am
Phil Parkin (6/28/2012)
...ChrisM - think you've got some tuning to do 🙂...
It's awful isn't it! I don't think it can be improved either.
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
June 29, 2012 at 2:06 am
patrickmcginnis59 (6/27/2012)
ChrisM@Work (6/27/2012)
SET @STRSQL = 'INSERT INTO ' + @DB...
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
June 29, 2012 at 2:03 am
@CLASSIFICACAO is declared as an int, you have to cast it as a string type to concatenate it into the string:
SET @STRSQL = 'INSERT INTO ' + @DB + '.DBO.SINCRONISMO...
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
June 27, 2012 at 9:29 am
You should be able to figure it out from this:
SELECT x.months, [YYYYMM] = CAST(CONVERT(CHAR(6),Months,112) AS INT)
FROM (VALUES (0),(1),(2),(3),(4),(5),(6)) r (n)
CROSS APPLY (SELECT Months = DATEADD(mm,-n,GETDATE())) x
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
June 27, 2012 at 8:53 am
ramadesai108 (6/26/2012)
Create PROCEDURE [dbo].[MySP]
(
@OrgId int,
@DivId int = null,
@EmpId nVarChar(MAX) = NULL,
@year int
)
AS
DECLARE @sql nVARCHAR(MAX)
DECLARE...
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
June 27, 2012 at 8:43 am
@River1, here are two useful hints for you:
1. Don't encapsulate a batch of statements into a stored procedure until you've finished debugging them - it's much easier to debug a...
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
June 27, 2012 at 8:28 am
Viewing 15 posts - 6,151 through 6,165 (of 10,143 total)