Forum Replies Created

Viewing 15 posts - 526 through 540 (of 2,462 total)

  • RE: Check if both fields from table B are in table A

    Francis Twomey (8/22/2016)


    Thanks for the responses. Here is my code currently:

    INSERT INTO item_relation_table

    (parent__id,

    child__id,

    relation)

    SELECT xm.1_id, xm.2_ID,

    'A',

    from tablexm xm

    where xm.1_id != xm.2_ID and

    exists(select 1 from item ip WHERE ip.mfg =...

    "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 do I assign the correct date ?

    This should be fine with SQL Server 2005+

    -- sample data

    CREATE TABLE #calendarTable (calDate datetime NOT NULL, workingDay char(1) NOT NULL);

    WITH base AS

    (

    SELECT TOP (366)

    ...

    "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: Selective updates to NULL

    I have a couple ideas I'll play around with when I'm at a PC shortly.

    non-nullable Tinyint having (-1,0,1) as possible values

    tinyint can't be negative 😉

    "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: Is SQL Server Replication going away?

    DentalDBA (8/18/2016)


    Does anyone know if Microsoft is thinking about doing away or not supporting database replication in the future? Do they have other ways to copy transaction changes?

    Thanks

    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: Data Warehouse Design Question

    My question is would it be better to create a Stage and House for each customer instead of the single method we are doing now? Some of our fact tables...

    "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: DynamicDateRangeGenerator

    ... and if we're talking about always doing 3 years behind/ahead of the current year you could even do this:

    WITH currentYear AS (SELECT yr = YEAR(getdate()))

    SELECT yr = yr +...

    "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: Loop through an integer and test the values and update with a char

    The NGRAMS tool you wrote is very cool. Don't blame you a bit. 🙂

    😀

    "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: Indexes

    The confusing thing about clustered indexes and primary keys is how, by default, SQL server uses the PK columns as the keys for the clustered index when you create 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: Loop through an integer and test the values and update with a char

    Jeff Moden (8/17/2016)


    Just an opinion... you just about can't beat a Nested Replace, like what Scott wrote, for something like this. I say "just about" only because I don't...

    "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: Confused about backups and recovery models

    Here's a good article by Gail Shaw that discusses Recovery Model internals and has some really good links about what's going on under the hood (if that's what you're looking...

    "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: Loop through an integer and test the values and update with a char

    A couple other ways:

    1. Use NGrams8K[/url] like so:

    DECLARE @price decimal(12,2) = 12345678.90;

    SELECT NewPrice =

    (

    SELECT CASE WHEN token LIKE '[0-9]' THEN CHAR(ASCII(token)+17) ELSE token END

    FROM dbo.NGrams8k(@price,...

    "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: Quick question on Full-Text Indexes

    It's likely that both versions will produce the same execution plan. I would probably go without the CTE because the first query is less complicated. That said, it may be...

    "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: Date gaps between date spans

    This is a classic gaps/islands problem. Have a look at this article:

    https://www.simple-talk.com/sql/t-sql-programming/the-sql-of-gaps-and-islands-in-sequences/%5B/url%5D

    "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: Question on Extended event

    vsamantha35 (8/15/2016)


    Is there a way using dmvs / trace to get know the the timeout set for a query? I can ask the application team but I am curious to...

    "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: tokenize string into key value pairs

    That's a mighty big font you got there.

    A complete solution will take some time but here's a couple techniques to break your input string into a seperate row for...

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