Viewing 15 posts - 256 through 270 (of 898 total)
subhajeetsur (5/22/2013)
u can use between while joining as said in above post but then it will not be optimized solution as ur query performance will hamper.
Do you have any other...
How to post data/code on a forum to get the best help - Jeff Moden
http://www.sqlservercentral.com/articles/Best+Practices/61537/
May 22, 2013 at 4:17 am
subhajeetsur (5/22/2013)
you can use row number with partitions to do the same
I think that is exactly what Lynn has suggested above.
How to post data/code on a forum to get the best help - Jeff Moden
http://www.sqlservercentral.com/articles/Best+Practices/61537/
May 22, 2013 at 4:13 am
This might help you
; WITH PRODUCT1 AS
(
SELECT*, DENSE_RANK() OVER( ORDER BY P.PARENT ) AS RN, 1 AS Lvl
FROMPRDST AS P
WHEREP.PARENT IN ( 1055874, 1055872 )
UNION ALL
SELECTPR.*, PR1.RN, PR1.Lvl + 1
FROMPRDST...
How to post data/code on a forum to get the best help - Jeff Moden
http://www.sqlservercentral.com/articles/Best+Practices/61537/
May 22, 2013 at 1:52 am
You will need a CTE to achieve the results
DECLARE@table TABLE
(
IdINT,
NameVARCHAR(10),
Value1INT,
value2INT,
PreviousRowId INT
)
INSERT@table
SELECT1, 'A', 10, 0, 0 UNION ALL
SELECT2, 'B', 0, 5, 1 UNION ALL
SELECT3, 'C', 0, 6, 2 UNION ALL
SELECT4, 'D',...
How to post data/code on a forum to get the best help - Jeff Moden
http://www.sqlservercentral.com/articles/Best+Practices/61537/
May 22, 2013 at 1:04 am
tknecht 32495 (5/21/2013)
The searching I've done for doing what I need suggests using an update statement to add information...
How to post data/code on a forum to get the best help - Jeff Moden
http://www.sqlservercentral.com/articles/Best+Practices/61537/
May 21, 2013 at 9:05 am
The result you want is exactly the same as what you have.
Why are trying to update it or am i missing something?
How to post data/code on a forum to get the best help - Jeff Moden
http://www.sqlservercentral.com/articles/Best+Practices/61537/
May 21, 2013 at 8:47 am
vishnurajeshsat (5/21/2013)
Thank you kingston it works but if i want to get more than 1 product details (i.e. 1055874 , 1055872 , etc. ) then how to change the query.
Something...
How to post data/code on a forum to get the best help - Jeff Moden
http://www.sqlservercentral.com/articles/Best+Practices/61537/
May 21, 2013 at 8:40 am
lmacdonald (5/21/2013)
How to post data/code on a forum to get the best help - Jeff Moden
http://www.sqlservercentral.com/articles/Best+Practices/61537/
May 21, 2013 at 8:30 am
shohelr2003 (5/21/2013)
Kingston Dhasian (5/21/2013)
Do you have scheduled log backups or do you monitor and take the log backups manually?I have not scheduled it but I do it manually.
It would be...
How to post data/code on a forum to get the best help - Jeff Moden
http://www.sqlservercentral.com/articles/Best+Practices/61537/
May 21, 2013 at 6:26 am
shohelr2003 (5/21/2013)
How to post data/code on a forum to get the best help - Jeff Moden
http://www.sqlservercentral.com/articles/Best+Practices/61537/
May 21, 2013 at 4:23 am
You can use a CTE to do this
; WITH PRODUCT1 AS
(
SELECT*
FROMPRDST AS P
WHEREP.PARENT = 1055874
UNION ALL
SELECTPR.*
FROMPRDST AS PR
INNER JOIN PRODUCT1 AS PR1 ON PR.PARENT = PR1.CHILD
)
SELECT*
FROMPRODUCT1
How to post data/code on a forum to get the best help - Jeff Moden
http://www.sqlservercentral.com/articles/Best+Practices/61537/
May 21, 2013 at 2:48 am
philip.davy (5/21/2013)
HiI've worked out the problem.
from members_.memberID_ with (nolock)
shouldn't have memberID_ in the SQL
Thanks
Great you could find it out 🙂
How to post data/code on a forum to get the best help - Jeff Moden
http://www.sqlservercentral.com/articles/Best+Practices/61537/
May 21, 2013 at 2:29 am
eklavu (5/21/2013)
TOP (1) should be in your main table not on the derived table "sgn"
SELECT TOP...
How to post data/code on a forum to get the best help - Jeff Moden
http://www.sqlservercentral.com/articles/Best+Practices/61537/
May 21, 2013 at 2:26 am
SELECTmth, qty,
SIGN( S1.qty -
(
SELECT TOP (1) qty
FROM dbo.Sales AS S2
WHERE S2.mth < S1.mth
ORDER BY S2.mth DESC
/*
This query is part of your SELECT statement
It will always return a single value
That value...
How to post data/code on a forum to get the best help - Jeff Moden
http://www.sqlservercentral.com/articles/Best+Practices/61537/
May 21, 2013 at 2:20 am
from members_.memberID_ with (nolock)
Do you have a table named memberId_ which belongs to the schema members_ ?
How to post data/code on a forum to get the best help - Jeff Moden
http://www.sqlservercentral.com/articles/Best+Practices/61537/
May 21, 2013 at 2:09 am
Viewing 15 posts - 256 through 270 (of 898 total)