Forum Replies Created

Viewing 15 posts - 7,306 through 7,320 (of 7,602 total)

  • RE: Differences between LIKE and LEFT/RIGHT selects

    Loner (7/13/2012)


    Please see

    http://www.mssqltips.com/sqlservertip/1236/avoid-sql-server-functions-in-the-where-clause-for-performance/

    LEFT() is a function it would result in an index scan where like '% %' would result in index seek which is more efficient.

    Not quite.

    LIKE 'xxx%' can...

  • RE: Need help on a Sql Query

    I don't think you really need indexing, since you can do everything in a single pass of the table, w/o JOINs, etc..

    SELECT

    ACTIONID,

    CASE...

  • RE: Updating Unique Sequential NUmber

    Lynn Pettis (7/11/2012)


    Matt Miller (#4) (7/11/2012)


    Lynn Pettis (7/11/2012)


    This works as well:

    CREATE TABLE [dbo].[TEST1](

    [ID] [VARCHAR](10) NULL,

    [VALUE] [int] NULL

    );

    GO

    INSERT INTO dbo.TEST1 (ID, VALUE) SELECT 1, 10;

    SELECT 'PRE' LABEL1, * FROM dbo.TEST1;

    DECLARE @SAVE1...

  • RE: Updating Unique Sequential NUmber

    Lynn Pettis (7/11/2012)


    ScottPletcher (7/11/2012)


    gerard-593414 (7/11/2012)


    I have a table which holds the next Invoice Number. What SP code should I use to increment it (Cant be self incrementing)

    There are numerous...

  • RE: Updating Unique Sequential NUmber

    gerard-593414 (7/11/2012)


    I have a table which holds the next Invoice Number. What SP code should I use to increment it (Cant be self incrementing)

    There are numerous users and want...

  • RE: optimization of query

    I think the query below is equivalent to your original one, w/o all the unnecessary join (unless the join on DAY restricts the rows selected from the "report" table). ...

  • RE: Another sql query

    cfradenburg (7/10/2012)


    ScottPletcher (7/10/2012)


    Jeff Moden (7/9/2012)


    ScottPletcher (7/9/2012)


    SELECT

    (ident - 1) % 3,

    MAX(CASE WHEN (ident - 1) % 3 = 0 THEN value ELSE 0...

  • RE: Another sql query

    Jeff Moden (7/9/2012)


    ScottPletcher (7/9/2012)


    SELECT

    (ident - 1) % 3,

    MAX(CASE WHEN (ident - 1) % 3 = 0 THEN value ELSE 0 END) AS...

  • RE: Another sql query

    SELECT

    (ident - 1) % 3,

    MAX(CASE WHEN (ident - 1) % 3 = 0 THEN value ELSE 0 END) AS part,

    ...

  • RE: Not exists or Not In which one is better

    In general, I too prefer NOT EXISTS, although SQL will often generate identical plans for either one.

    It's definitely strongly preferred whenever possible to have an index to support the lookup,...

  • RE: PATINDEX and Regular Expression

    I think this gets you pretty close, w/o having to resort to CLR:

    WHERE

    --one +/- optional, but must be first if used

    PATINDEX('%[+-]%', varcharValue)...

  • RE: use of SET in an SP

    SQL Server explicitly discards SET values at the end of the stored proc and, AFAIK, there is absolutely no way to change that directly.

    You could, of course, save the desired...

  • RE: question on indexes

    Please substitute your db name below,

    and your table name in BOTH places below where <your_table_name> appears, then run the queries and post the results.

    USE <your_db_name>

    SELECT

    GETDATE()...

  • RE: question on indexes

    You likely should have (at least) column A as the clustered index on the table.

    Would need more details and info to determine if another column(s) should be in the clus...

  • RE: Best way to implement partitioning

    SQLKnowItAll (7/9/2012)


    ScottPletcher (7/9/2012)


    SQLKnowItAll (7/9/2012)


    ScottPletcher (7/9/2012)

    I know why the date was left out of the Sales table -- it can be derived.

    What am I missing... How can it...

Viewing 15 posts - 7,306 through 7,320 (of 7,602 total)