Viewing 15 posts - 301 through 315 (of 1,438 total)
I don't think you'll need a tally/numbers table for this. A single query should do it.
INSERT INTO @ResultsTable
SELECT fis.SalesOrderNumber
, dp.EnglishProductName
...
August 12, 2013 at 3:21 am
Looks like a straightforward recursive query
DECLARE @t TABLE(Col1 CHAR(2), Col2 CHAR(2))
INSERT INTO @t(Col1,Col2)
VALUES
('G1', 'G2'),
('G3', 'P1'),
('P1', 'P2'),
('P2', 'G4'),
('G5', 'G6'),
('G7', 'G8');
WITH Recur AS (
SELECT t1.Col1 As Root,t1.Col2
FROM @t t1
WHERE NOT EXISTS(SELECT *...
August 12, 2013 at 1:54 am
Koen Verbeeck (8/8/2013)
August 9, 2013 at 5:59 am
You don't actually need the '/', that's just for clarity to show the sort order for each part of the hierarchy. The sort order value just has to be fixed...
August 7, 2013 at 7:49 am
rajg (8/7/2013)
This is perfect...Thankkkkk you very much !! Dont know why I spent so much of time on this 🙂
You're welcome.
August 7, 2013 at 7:35 am
Is this what you're after?
WITH Source AS (
SELECT [TIME_ID], , [DESCRIPTION], [PARENT_ID], CAST(1000+ROW_NUMBER() OVER(ORDER BY [SORTORDER]) AS VARCHAR(10)) AS [SORTORDER]
FROM tblTime),
Recur AS (
SELECT [TIME_ID], , [DESCRIPTION], [PARENT_ID], CAST([SORTORDER] AS VARCHAR(1000))...
August 7, 2013 at 7:27 am
Lots of ways of doing this, here's one
WITH dpCTE AS (
SELECT [nr],
[type],
[DT],
RANK() OVER(PARTITION BY [DT] ORDER BY...
August 6, 2013 at 6:33 am
Try this
WITH Starts AS (
SELECT a.StationID,a.dtmStart,
ROW_NUMBER() OVER(PARTITION BY a.StationID ORDER BY a.dtmStart) AS rn
FROM @Events a
WHERE NOT EXISTS(SELECT * FROM @Events b
...
August 6, 2013 at 2:35 am
You can use '&' for decoding @@OPTIONS
PRINT @@OPTIONS
IF ( (8 & @@OPTIONS) = 8 ) PRINT 'ANSI_WARNINGS'
IF ( (16 & @@OPTIONS) = 16 ) PRINT 'ANSI_PADDING'
IF ( (32 & @@OPTIONS)...
July 24, 2013 at 9:13 am
WITH CTE AS (
SELECT acctno , email_id,
ROW_NUMBER() OVER(PARTITION BY acctno ORDER BY CASE WHEN email_id LIKE '%dell.com%' THEN 0 ELSE 1 END, email_id)...
July 23, 2013 at 9:14 am
What are your current settings and the stored procedure settings for ANSI_NULLS, CONCAT_NULL_YIELDS_NULL etc?
July 23, 2013 at 4:43 am
DECLARE @T1 TABLE(ID INT, Dept CHAR(3), Cat INT)
INSERT INTO @T1(ID,Dept,Cat)
VALUES
(1, 'WER', 2),
(2, 'TTR', 7);
DECLARE @T2 TABLE(ID INT, [Date] DATE, Type CHAR(2))
INSERT INTO @T2(ID, [Date], Type)
VALUES
(1, '2013-07-01', 'GA'),
(2, '2013-07-04', 'FS'),
(2, '2013-07-08',...
July 23, 2013 at 2:21 am
Paul White posted an interesting item about MERGE here
July 19, 2013 at 9:06 am
Viewing 15 posts - 301 through 315 (of 1,438 total)