Forum Replies Created

Viewing 15 posts - 511 through 525 (of 2,458 total)

  • RE: Check constraint based on other tables

    Welcome to the SQLServerCentral forums.

    This should be easy to sort out but it would help if you could provide some DDL, a few rows of sample data and an...

    "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: Converting a XML datatype to varchar(max).

    ben.brugman (8/23/2016)

    I would like a solution without the FOR XML, is there one ?

    I think there is. I generally avoid scalar user defined functions like the plague but check this...

    "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: Converting a XML datatype to varchar(max).

    Matt Miller (#4) (8/24/2016)


    mister.magoo (8/24/2016)


    Sergiy (8/24/2016)


    mister.magoo (8/23/2016)


    To answer your question about how (not getting involved in why)

    declare @x xml;

    select @x=(

    select ''+b

    from

    (

    select 'hello;friend'+CHAR(13)+CHAR(10)

    union all

    select 'my;world'+CHAR(13)+CHAR(10)

    )a(b)

    for xml path(''),type);

    select @x.value('(./text())[1]','nvarchar(max)')

    the important things...

    "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: Converting a XML datatype to varchar(max).

    ben.brugman (8/23/2016)


    XML

    is not the purpose and not a target it is only the means to get to something.

    So why FOR XML? The reason for this is that FOR XML concatenates...

    "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 we send a SSRS report by email based on a condition

    Have a look at Data Driven Subscriptions.

    "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 Performance help needed

    It looks like you can re-write your code to eliminate the cursor - that cursor is going to slow you down. I would also run this stored procedure using 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: Converting a XML datatype to varchar(max).

    With FOR XML a large string is build from tablecontent.

    The result is stored as a XML datatype in a table.

    What is the purpose of this?

    If the primary purpose is...

    "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: Job to Back Up DB structures only

    As Phil eluded to, this is best handled via source control. Another way to get collect definitions is to use dbo.sp_GetDDL[/url]

    This is a script I use to pull all your...

    "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: Temp Table 'vs' Table Variable 'vs' CTE.

    growlingly poor English

    :hehe::hehe::hehe: +1

    I never heard the word growlingly before so I looked up the Webster definition.

    Growl´ing`ly

    adv.1.In a growling manner.

    "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: Optimize update with an index

    The only way to know what's happening now and how adding an index will change things is to look at the execution plan before and after and test it.

    Based on...

    "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: What is the impact of setting SET ANSI_WARNINGS OFF?

    Great article. Well done. Scary.

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

Viewing 15 posts - 511 through 525 (of 2,458 total)