Forum Replies Created

Viewing 15 posts - 2,146 through 2,160 (of 2,462 total)

  • RE: Help On Query

    I am not recommending that you use this but query, I am posting it for reference. It will produce the same result and it's easier to read & understand.

    DECLARE @listStr...

    "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: How to Split String

    The correct way to split a string using T-SQL would be to use Jeff's splitter as Louis mentioned. That said, what you are doing is quite simple; you could do...

    "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: Help with this query please.

    Also,

    I'd get rid of those NOLOCK table hints. NOLOCK (READ UNCOMMITTED) is for when you don't care if you always get the right answer. Here's a good article about that:

    SQL...

    "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: Help with this query please.

    The error you are getting is true: GROUP BY/HAVING,etc are not allowed in the recursive part of a CTE. It does not look like you are trying to do 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: Combining 2 queries

    Something like this perhaps...

    -- your data

    DECLARE @Report1 TABLE (contract varchar(20), A int, E int, N int, P int);

    INSERT @Report1

    SELECT 'Income', 5000, 6000, 8000, 4000 UNION

    SELECT 'Costs', 4000, 7000,...

    "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: patindex alternative in SSIS

    If you can use CLRs you could look at mdq.regexmatches. See this thread.

    "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: Call SP foreach Column in Table (without Cursor)

    opc.three (8/19/2013)


    Here is a non-cursor option, just for the sake of having an alternative to using a cursor:

    DECLARE @sql NVARCHAR(MAX) = N'';

    SELECT @sql += 'EXEC LoadFile ' + QUOTENAME(FILENAME, '''')...

    "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: Dynamic Sorting Issue

    Thanks Luis!

    "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: Need help in query...

    -- (1) Source Data

    DECLARE @nbrs TABLE (n int primary key);

    INSERT @nbrs VALUES (10),(20),(30),(40),(50);

    -- (2) Solution

    WITH

    s1 AS (SELECT ROW_NUMBER() OVER (ORDER BY n) AS rn,n FROM @nbrs),

    s2 AS (SELECT rn-1...

    "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: Allow developers to install sql express on desktops?

    First, I second both responses to your question. I actually have a couple versions of SQL server installed on my machine: 2008R2 Developer Edition & SQL Server 2012 Express. Developer...

    "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 with EXCEPT statement

    I have run into the exact same type of thing...

    /bangs head.

    This is the cause of my receding hairline. :hehe:

    "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 with EXCEPT statement

    the source data is coming from a database in the UK and the values sometimes contain non alpha-numeric characters. i'm probably wrong, but i'm wondering if some of these characters...

    "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 with EXCEPT statement

    Shot in the dark here but, are you using a case sensitive collation?

    "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: Case statements advice - query case field?

    learning_sql (8/13/2013)


    Ha, it literally said "Reporting Services does not support CROSS APPLY".

    However I have just been playing around and when just typing the query it worked every time, I have...

    "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: Case statements advice - query case field?

    dwain.c (8/12/2013)


    Alan.B (8/12/2013)


    Instead of the case statement you can also do this:

    SELECT ISNULL(thing1.name,(ISNULL(thing2.name,thing3.name))) AS name

    And why not:

    SELECT COALESCE(thing1.name,thing2.name,thing3.name) AS name

    ?

    Nice. That is cleaner and easier to read.

    +1

    "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,146 through 2,160 (of 2,462 total)