Viewing 15 posts - 7,516 through 7,530 (of 8,731 total)
A method using CROSS APPLY could work for you.
More information in this article: http://www.sqlservercentral.com/articles/CROSS+APPLY+VALUES+UNPIVOT/91234/
SELECT ID, Attribute1, Attribute2, Period, Metric1,Metric2 FROM #Things
CROSS APPLY (VALUES('OneMonth',OneMonthMetric1,OneMonthMetric2),
('TwoMonth',TwoMonthMetric1,TwoMonthMetric2),
('ThreeMonth',ThreeMonthMetric1,ThreeMonthMetric2))x(Period, Metric1,Metric2)
October 31, 2013 at 1:53 pm
In this case it can work the same way, but it won't always be like that. Don't let the word CROSS confuse you as the real operators are JOIN and...
October 31, 2013 at 1:07 pm
You're not putting a smaller number into a bigger one. You should try decimal(24,8).
decimal(22,6) ranges are
-9,999,999,999,999,999.999999 to 9,999,999,999,999,999.999999
decimal(22.8) are
-99,999,999,999,999.99999999 to 99,999,999,999,999.99999999
so they are significantly smaller (100 times).
That's why you...
October 31, 2013 at 1:05 pm
CLR might perform very well, but it seems to me that you're cracking nuts with a sledgehammer (or as said in spanish, killing flies with cannonballs).
Your bottleneck was CPU using...
October 31, 2013 at 12:16 pm
There are some basic routines for datetime calculations.
Here's what you need.
SELECT DATEADD( DAY, DATEDIFF(DAY, 0, sampledate), 0)
FROM( SELECT CAST( '20130722 04:01:08PM' AS datetime) sampledate)x
And here are some more:
http://www.sqlservercentral.com/blogs/lynnpettis/2009/03/25/some-common-date-routines/
October 31, 2013 at 12:02 pm
npatel565 (10/31/2013)
The loop version returns the result set returns 4 rows, 2 for each accountid.Accountid,RID,date,users
11,10,2013-10-31 17:21:27.203,John
11,50,2013-10-31 17:21:27.203,John
15,10,2013-10-31 17:21:27.203,John
15,50,2013-10-31 17:21:27.203,John
This is the correct answer.
My solution returns exactly those...
October 31, 2013 at 11:58 am
I might be missing something, but your code seems to be doing the following:
DECLARE @users VARCHAR(20) = 'John',
@LoadedDate DATETIME2(7) = GETUTCDATE()
SELECT DISTINCT Accountid,
Rid,
@LoadedDate,
@users
FROM #TEMP
CROSS JOIN #Ramp
DELETE
FROM #EAA
WHERE RID IN (
SELECT...
October 31, 2013 at 9:51 am
What edition are you using?
You could use snapshots or CDC(Change Data Capture) on Enterprise edition.
October 30, 2013 at 7:09 pm
Ed Wagner (10/30/2013)
Luis Cazares (10/30/2013)
ahmedhussein874 (10/30/2013)
Thanks a lot Luis .. Can I handle it without functions ?? is there any other alternative way ??
There might be, but it might take...
October 30, 2013 at 1:02 pm
I wasn't saying that stored procedures save a log automatically, but are a simple way to manage your T-SQL code without touching the SSIS packages.
For the error logging, take a...
October 30, 2013 at 9:57 am
below86 (10/30/2013)
October 30, 2013 at 9:30 am
ahmedhussein874 (10/30/2013)
Thanks a lot Luis .. Can I handle it without functions ?? is there any other alternative way ??
There might be, but it might take me a while to...
October 30, 2013 at 9:19 am
Stefan Krzywicki (10/29/2013)
It is knowledge either way. And there is value in communicating what you would do, that doesn't mean you need to display it by fixing their problems for...
October 29, 2013 at 7:01 pm
A different approach:
WITH DistinctIds AS(
select id, MIN( rnk) rnk
from #tester
group by id
),
Counts AS(
select id, ROW_NUMBER() OVER( ORDER BY rnk) newrank
FROM DistinctIds
)
SELECT t.*, c.newrank
FROM #tester t
JOIN Counts c ON t.id =...
October 29, 2013 at 4:50 pm
I won't post the function because that would be too easy for you and you won't learn.:-)
However, I'll leave you a link to the article that explains how it works...
October 29, 2013 at 1:52 pm
Viewing 15 posts - 7,516 through 7,530 (of 8,731 total)