Forum Replies Created

Viewing 15 posts - 2,296 through 2,310 (of 2,462 total)

  • RE: LIKE Operator OR Regular Expressions?

    SQLWannabe (2/25/2013)


    Lynn,

    Holy cr@p, that's exactly what I want.

    I didn't even think about the collation.

    So since my collation is: SQL_Latin1_General_CP1_CI_AS, I need to change the collation?

    Can you give me...

    "I cant stress enough the importance of switching from a sequential files mindset to set-based thinking. After you make the switch, you can spend your time tuning and optimizing your queries instead of maintaining lengthy, poor-performing code."

    -- Itzik Ben-Gan 2001

  • RE: Please help my carrer Path?

    I started my technical career working on mainframes and switched to a database support role. Since then I have worked in the data world as a DBA, SQL Developer and...

    "I cant stress enough the importance of switching from a sequential files mindset to set-based thinking. After you make the switch, you can spend your time tuning and optimizing your queries instead of maintaining lengthy, poor-performing code."

    -- Itzik Ben-Gan 2001

  • RE: consecutive days count irrespective of weekends, holidays

    Using the sample code I created before you can also get days in/days not in using this:

    DECLARE @startdate bigint=20121101,

    @endDate bigint=20121130;

    ;WITH

    notthere AS

    (SELECTStudentID, COUNT(*) AS DaysAbs

    FROM #x

    WHERE DateID>=@startdate AND DateID<=@endDate

    AND...

    "I cant stress enough the importance of switching from a sequential files mindset to set-based thinking. After you make the switch, you can spend your time tuning and optimizing your queries instead of maintaining lengthy, poor-performing code."

    -- Itzik Ben-Gan 2001

  • RE: consecutive days count irrespective of weekends, holidays

    This should do the trick:

    -- Setup

    IF OBJECT_ID('tempdb..#x') IS NOT NULL

    DROP TABLE #x;

    CREATE TABLE #x

    ( Studentid int, DateID bigint unique, attendaceind bit)

    INSERT INTO #x

    SELECT 1234, 20121031, 1 UNION ALL

    SELECT...

    "I cant stress enough the importance of switching from a sequential files mindset to set-based thinking. After you make the switch, you can spend your time tuning and optimizing your queries instead of maintaining lengthy, poor-performing code."

    -- Itzik Ben-Gan 2001

  • RE: Query Help

    DBA12345 (2/5/2013)


    Thanks alot...I appreciate your help

    NP

    "I cant stress enough the importance of switching from a sequential files mindset to set-based thinking. After you make the switch, you can spend your time tuning and optimizing your queries instead of maintaining lengthy, poor-performing code."

    -- Itzik Ben-Gan 2001

  • RE: Query Help

    This should do the trick:

    --Setup

    IF OBJECT_ID('tempdb..#t1') IS NOT NULL

    DROP TABLE #t1;

    IF OBJECT_ID('tempdb..#t2') IS NOT NULL

    DROP TABLE #t2;

    CREATE TABLE #t1 ([Server] varchar(10) primary key,

    [Name] varchar(10) NOT NULL,

    ...

    "I cant stress enough the importance of switching from a sequential files mindset to set-based thinking. After you make the switch, you can spend your time tuning and optimizing your queries instead of maintaining lengthy, poor-performing code."

    -- Itzik Ben-Gan 2001

  • RE: Better Way to Perform this Query

    Jeff Moden (1/10/2013)


    Alan.B (1/10/2013)


    This morning before work for example, after a lot of effort, I finally figured out how to get the Levenshtein Edit Distance between 2 strings without a...

    "I cant stress enough the importance of switching from a sequential files mindset to set-based thinking. After you make the switch, you can spend your time tuning and optimizing your queries instead of maintaining lengthy, poor-performing code."

    -- Itzik Ben-Gan 2001

  • RE: Better Way to Perform this Query

    Greg Snidow (1/11/2013)


    Alan.B

    I came up with this:

    -- strings to compare

    DECLARE@s1 varchar(8000)='diner',

    @s2 varchar(8000)='dinerr';

    DECLARE @ld int=ABS(LEN(@s1)-LEN(@s2));

    IF ((@s1=@s2) OR ((ISNULL(LEN(@s1)*LEN(@s2),0)=0))) BEGIN GOTO LD END;

    DECLARE@minlen int=CASE WHEN LEN(@s1)>LEN(@s2) THEN LEN(@s2) ELSE LEN(@s1) END;

    ;WITH...

    "I cant stress enough the importance of switching from a sequential files mindset to set-based thinking. After you make the switch, you can spend your time tuning and optimizing your queries instead of maintaining lengthy, poor-performing code."

    -- Itzik Ben-Gan 2001

  • RE: Problem in installing sql server 2012

    soni321 (1/10/2013)


    yes it is sql server 2012 developer.i have windows7 home premium.Error says i need windows 7 sp1.now my question is i have home preium window 7 i am able...

    "I cant stress enough the importance of switching from a sequential files mindset to set-based thinking. After you make the switch, you can spend your time tuning and optimizing your queries instead of maintaining lengthy, poor-performing code."

    -- Itzik Ben-Gan 2001

  • RE: Problem in installing sql server 2012

    Based on what you are saying I think you mean SP1 (Service Pack1)... And is this SQL Server 2012 Express?

    You may just need to run Service Pack 1.

    What...

    "I cant stress enough the importance of switching from a sequential files mindset to set-based thinking. After you make the switch, you can spend your time tuning and optimizing your queries instead of maintaining lengthy, poor-performing code."

    -- Itzik Ben-Gan 2001

  • RE: Problem in installing sql server 2012

    What's the error?

    "I cant stress enough the importance of switching from a sequential files mindset to set-based thinking. After you make the switch, you can spend your time tuning and optimizing your queries instead of maintaining lengthy, poor-performing code."

    -- Itzik Ben-Gan 2001

  • RE: Better Way to Perform this Query

    Sean Lange (1/10/2013)


    Alan.B (1/10/2013)


    I agree that I should have used a tally table. I've been writing CTE's for counting for awhile and can do so while sleeping. I still fumble...

    "I cant stress enough the importance of switching from a sequential files mindset to set-based thinking. After you make the switch, you can spend your time tuning and optimizing your queries instead of maintaining lengthy, poor-performing code."

    -- Itzik Ben-Gan 2001

  • RE: Better Way to Perform this Query

    Jeff Moden (1/9/2013)


    Alan.B (1/9/2013)


    AndrewSQLDBA (1/9/2013)


    Its worth noting that the following is sargable.

    LIKE '%abc%'

    Did you mean "NOT" SARGable because it sure doesn't look SARGable from here. 😉 And,...

    "I cant stress enough the importance of switching from a sequential files mindset to set-based thinking. After you make the switch, you can spend your time tuning and optimizing your queries instead of maintaining lengthy, poor-performing code."

    -- Itzik Ben-Gan 2001

  • RE: Better Way to Perform this Query

    dwain.c (1/9/2013)


    Alan - That's a very intriguing use of NTILE!

    I would recommend, however that you change the way you construct your asciichar table:

    ;WITH asciichar(n, c) AS (

    SELECT n=64+number, CHAR(64+number)

    FROM [master].dbo.spt_values...

    "I cant stress enough the importance of switching from a sequential files mindset to set-based thinking. After you make the switch, you can spend your time tuning and optimizing your queries instead of maintaining lengthy, poor-performing code."

    -- Itzik Ben-Gan 2001

  • RE: "USE DATABASE" in stored procedure

    My appologies. In my last post I misread your question. Hopefully what GSquared posted helped.

    "I cant stress enough the importance of switching from a sequential files mindset to set-based thinking. After you make the switch, you can spend your time tuning and optimizing your queries instead of maintaining lengthy, poor-performing code."

    -- Itzik Ben-Gan 2001

Viewing 15 posts - 2,296 through 2,310 (of 2,462 total)