Forum Replies Created

Viewing 15 posts - 1,096 through 1,110 (of 2,458 total)

  • RE: Get pick list from XML data file

    Using your attached example you would modify the XPath Expression like so

    *:StaffingOrder/*:StaffingPosition/*:CustomFields/*:CustomField[@name="Reason for Request"]/*:pickList/*:item'

    Here's the full solution:

    DECLARE @x XML =

    '<?xml version="1.0" encoding="UTF-8"?>

    <StaffingOrder xmlns="jobPosting" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="jobPosting https://xuat.fgvms.com/schema/InSiteJobPostingV2.xsd">

    <OrderId validFrom="12/31/2015"...

    "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: Trying to CROSS JOIN a table and a function without success

    IF you want to pass columns to a table valued function like that you need to use APPLY. I suspect that this will work for you:

    SELECT RigsVolTable

    , Try_convert(float,...

    "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: Rewrite query for better performance

    Can you post some DDL and the execution plan?

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

    tt-615680 (12/16/2015)


    SET NOCOUNT ON;

    Exec sp_MSforeachdb 'USE ?

    DECLARE @objectid int;

    DECLARE @indexid int;

    DECLARE @partitioncount bigint;

    DECLARE @schemaname nvarchar(130);

    DECLARE @objectname nvarchar(130);

    DECLARE @indexname nvarchar(130);

    DECLARE @partitionnum bigint;

    DECLARE @partitions bigint;

    DECLARE @frag float;

    DECLARE @command nvarchar(4000);

    DECLARE @dbid smallint;

    SET @dbid...

    "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: Using Multi-result subquery in expression

    stevennjuki (12/16/2015)


    Thanks, but the solution provided by Drew is scalable, which is what I wanted. Thanks any way

    Cool. On a side note for future reference about UNION... UNION ALL pretty...

    "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: Using Multi-result subquery in expression

    John more-or-less beat me to it and drews solution is probably better but here's what I came up with. Using an inline table valued function you could do this:

    USE tempdb

    GO

    --...

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

    MAXDOP restricts the number of CPUs that can be used in a parallel query plan. MAXDOP 0 let's SQL Server use as many as SQL Server wants (up to 64...

    "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: Get pick list from XML data file

    Phil Parkin (12/15/2015)


    Nice one, Alan. Much tidier.

    Thanks Phil...

    And since I had a few minutes to kill during lunch, a set-based solution that uses no XML...

    -- declaring as varchar 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

  • RE: Get pick list from XML data file

    another way...

    DECLARE @x XML = '<?xml version="1.0" encoding="UTF-8"?>

    <StaffingOrder>

    <OrderId validFrom="12/31/2015" validTo="12/31/2015">

    <IdValue>JNJNJP00040440</IdValue>

    <Status>Submitted</Status>

    </OrderId>

    <StaffingPosition>

    <CustomFields>

    ...

    "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: Analysing Sales Patterns: R + SQL Server

    Great article!

    "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: The Years of Experience

    paul.kemner (12/15/2015)


    The flip side is that a lot of consulting companies will grossly oversell your skillset to get a paying contract. They'll sell you as an expert in xyz language,...

    "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: The Years of Experience

    Quality experience is always better than quantity. I have interviewed a lot of people who, on paper, looked pretty good but after 30 minutes I had no idea what they...

    "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: Has anyone seen T-SQ like this (A space after the tablie alias and before the column name

    Gazareth (12/14/2015)


    Alan.B (12/14/2015)


    -- THIS:

    SELECT t. Col1, t.col2

    FROM #t1 t

    -- IS THE SAME AS THIS:

    SELECT t.[ ] AS Col1, t.col2

    FROM #t1 t

    No it isn't. 1st one returns contents of...

    "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: Has anyone seen T-SQ like this (A space after the tablie alias and before the column name

    <removed>... Posted twice somehow.

    "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: Has anyone seen T-SQ like this (A space after the tablie alias and before the column name

    I have never seen that but it's possible to have a column named <blank space>. Note the DDL below:

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

    CREATE TABLE #t1 ([ ]...

    "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 - 1,096 through 1,110 (of 2,458 total)