Forum Replies Created

Viewing 15 posts - 586 through 600 (of 2,894 total)

  • RE: Complex SQL QUERY with DateDIFF

    Mark-101232 (3/14/2013)


    Eugene Elutin (3/14/2013)


    "Looks like" - it just really "Looks like" nothing more. That is whole problem for recursive CTE's - they are fine for limited number of recursions, they...

    _____________________________________________
    "The only true wisdom is in knowing you know nothing"
    "O skol'ko nam otkrytiy chudnyh prevnosit microsofta duh!":-D
    (So many miracle inventions provided by MS to us...)

    How to post your question to get the best and quick help[/url]

  • RE: Complex SQL QUERY with DateDIFF

    "Looks like" - it just really "Looks like" nothing more. That is whole problem for recursive CTE's - they are fine for limited number of recursions, they not very well...

    _____________________________________________
    "The only true wisdom is in knowing you know nothing"
    "O skol'ko nam otkrytiy chudnyh prevnosit microsofta duh!":-D
    (So many miracle inventions provided by MS to us...)

    How to post your question to get the best and quick help[/url]

  • RE: Split A String into 4 parts

    Alan.B (3/13/2013)


    Eugene Elutin (3/13/2013)


    declare @filename varchar(100)

    set @filename = 'Notes_20130204_003015.txt';

    select PARSENAME(replace(@filename,'_','.'),4)

    select PARSENAME(replace(@filename,'_','.'),3)

    select PARSENAME(replace(@filename,'_','.'),2)

    select PARSENAME(replace(@filename,'_','.'),1)

    Fantastic use of PARSENAME! Wow!

    Not really. Quite slow one, actually. But will suite to the purpose...

    _____________________________________________
    "The only true wisdom is in knowing you know nothing"
    "O skol'ko nam otkrytiy chudnyh prevnosit microsofta duh!":-D
    (So many miracle inventions provided by MS to us...)

    How to post your question to get the best and quick help[/url]

  • RE: Convert String to Time Format

    or you can use something like this:

    DECLARE @time TABLE (StringTime VARCHAR(6))

    INSERT @time

    SELECT '112345'

    UNION SELECT '12345'

    UNION...

    _____________________________________________
    "The only true wisdom is in knowing you know nothing"
    "O skol'ko nam otkrytiy chudnyh prevnosit microsofta duh!":-D
    (So many miracle inventions provided by MS to us...)

    How to post your question to get the best and quick help[/url]

  • RE: Complex SQL QUERY with DateDIFF

    Those logtimes look sequential to me - are you sure?

    What do you mean by "sequential"? These LogTimes are for the same UserId, they are unique and they grow in its...

    _____________________________________________
    "The only true wisdom is in knowing you know nothing"
    "O skol'ko nam otkrytiy chudnyh prevnosit microsofta duh!":-D
    (So many miracle inventions provided by MS to us...)

    How to post your question to get the best and quick help[/url]

  • RE: Complex SQL QUERY with DateDIFF

    Cause some log data can be a bit different.

    Try this one:

    SET DATEFORMAT dmy;

    CREATE TABLE #Source (LogIndex int, UserID nvarchar (10), LogTime datetime, Tipo smallint);

    CREATE TABLE #Temp (LogIndex int, UserID nvarchar...

    _____________________________________________
    "The only true wisdom is in knowing you know nothing"
    "O skol'ko nam otkrytiy chudnyh prevnosit microsofta duh!":-D
    (So many miracle inventions provided by MS to us...)

    How to post your question to get the best and quick help[/url]

  • RE: CASE in WHERE clause

    Gail's blog recommends using dynamic SQL

    but our boss doesn't like it at all.

    Is your boss SQL Server professional or just an idiot with a lot of ambitions?

    For what you're...

    _____________________________________________
    "The only true wisdom is in knowing you know nothing"
    "O skol'ko nam otkrytiy chudnyh prevnosit microsofta duh!":-D
    (So many miracle inventions provided by MS to us...)

    How to post your question to get the best and quick help[/url]

  • RE: Stored Procedure runs slower than SQL Query Why??

    david.ostrander (3/13/2013)


    Hello -

    I created a Store Procedure to have Table A sync with Table B by doing an insert of the data that it does not have.

    The issue I'm...

    _____________________________________________
    "The only true wisdom is in knowing you know nothing"
    "O skol'ko nam otkrytiy chudnyh prevnosit microsofta duh!":-D
    (So many miracle inventions provided by MS to us...)

    How to post your question to get the best and quick help[/url]

  • RE: Split A String into 4 parts

    declare @filename varchar(100)

    set @filename = 'Notes_20130204_003015.txt';

    select PARSENAME(replace(@filename,'_','.'),4)

    select PARSENAME(replace(@filename,'_','.'),3)

    select PARSENAME(replace(@filename,'_','.'),2)

    select PARSENAME(replace(@filename,'_','.'),1)

    _____________________________________________
    "The only true wisdom is in knowing you know nothing"
    "O skol'ko nam otkrytiy chudnyh prevnosit microsofta duh!":-D
    (So many miracle inventions provided by MS to us...)

    How to post your question to get the best and quick help[/url]

  • RE: Complex SQL QUERY with DateDIFF

    ChrisM@Work (3/13/2013)


    Eugene Elutin (3/13/2013)


    Still running after 12 minutes.

    Some one around was looking for CPU killer query... I need to cancel that one!

    Hahahaha!

    I didn't say it would be faster, but...

    _____________________________________________
    "The only true wisdom is in knowing you know nothing"
    "O skol'ko nam otkrytiy chudnyh prevnosit microsofta duh!":-D
    (So many miracle inventions provided by MS to us...)

    How to post your question to get the best and quick help[/url]

  • RE: Complex SQL QUERY with DateDIFF

    Still running after 12 minutes.

    Some one around was looking for CPU killer query... I need to cancel that one!

    _____________________________________________
    "The only true wisdom is in knowing you know nothing"
    "O skol'ko nam otkrytiy chudnyh prevnosit microsofta duh!":-D
    (So many miracle inventions provided by MS to us...)

    How to post your question to get the best and quick help[/url]

  • RE: Complex SQL QUERY with DateDIFF

    Let's try on 1,000,000 rows:

    common test data setup parts:

    SET DATEFORMAT dmy;

    CREATE TABLE #Source (LogIndex int, UserID nvarchar (10), LogTime datetime, Tipo smallint);

    CREATE TABLE #Temp (LogIndex int, UserID nvarchar (10), LogTime...

    _____________________________________________
    "The only true wisdom is in knowing you know nothing"
    "O skol'ko nam otkrytiy chudnyh prevnosit microsofta duh!":-D
    (So many miracle inventions provided by MS to us...)

    How to post your question to get the best and quick help[/url]

  • RE: Complex SQL QUERY with DateDIFF

    Yep, that is right now.

    And it does look less code. But...

    Cause it's based on recursive CTE and hidden triangular join (via cross apply), it's performance very unlikely be on...

    _____________________________________________
    "The only true wisdom is in knowing you know nothing"
    "O skol'ko nam otkrytiy chudnyh prevnosit microsofta duh!":-D
    (So many miracle inventions provided by MS to us...)

    How to post your question to get the best and quick help[/url]

  • RE: Complex SQL QUERY with DateDIFF

    ChrisM@Work (3/13/2013)


    Eugene Elutin (3/13/2013)


    I'm sure you didn't mark rows to be "ok" for UserId 01552 correctly, please check carefully!

    01552 is correct, 01551 is incorrect:

    ;WITH OrderedData AS (

    SELECT *, seq =...

    _____________________________________________
    "The only true wisdom is in knowing you know nothing"
    "O skol'ko nam otkrytiy chudnyh prevnosit microsofta duh!":-D
    (So many miracle inventions provided by MS to us...)

    How to post your question to get the best and quick help[/url]

  • RE: Complex SQL QUERY with DateDIFF

    I'm sure you didn't mark rows to be "ok" for UserId 01552 correctly, please check carefully!

    SELECT IDENTITY(INT,1,1) RID,*, CAST(NULL AS BIT) AS Flag INTO #Work

    FROM #TEMP ORDER BY UserId,...

    _____________________________________________
    "The only true wisdom is in knowing you know nothing"
    "O skol'ko nam otkrytiy chudnyh prevnosit microsofta duh!":-D
    (So many miracle inventions provided by MS to us...)

    How to post your question to get the best and quick help[/url]

Viewing 15 posts - 586 through 600 (of 2,894 total)