Forum Replies Created

Viewing 15 posts - 7,516 through 7,530 (of 8,731 total)

  • RE: Undo the cross tab

    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)

  • RE: loop to set based (what am i doing wrong)

    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...

  • RE: Convert to numeric overflow issue

    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...

  • RE: udf very slow?

    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...

  • RE: Convert Time to AM

    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/

  • RE: loop to set based (what am i doing wrong)

    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...

  • RE: loop to set based (what am i doing wrong)

    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...

  • RE: Compare data in a database

    What edition are you using?

    You could use snapshots or CDC(Change Data Capture) on Enterprise edition.

  • RE: How can I handle the following query ??

    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...

  • RE: Any way to see or view the results of an execute sql task ?

    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...

  • RE: Any way to see or view the results of an execute sql task ?

    below86 (10/30/2013)


    So until someone can tell me how I can see this same type of 'log' information for an execution of a SQL job, I will not be using the...

  • RE: How can I handle the following query ??

    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...

  • RE: Are the posted questions getting worse?

    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...

  • RE: Running Count

    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 =...

  • RE: Need Advise...

    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...

Viewing 15 posts - 7,516 through 7,530 (of 8,731 total)