Forum Replies Created

Viewing 15 posts - 1,951 through 1,965 (of 2,462 total)

  • RE: XML To SQL conversion

    clucasi (5/28/2014)


    ...the problem I am having is that the XML has two row nodes.

    The deal with two nodes with the same name you could refer to them by their position....

    "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: XML To SQL conversion

    Eirikur Eiriksson (5/28/2014)


    Here is a very simple approach

    😎

    USE tempdb;

    GO

    DECLARE @TXML XML = N'<?xml version="1.0"?>

    <CommonEventData>

    <Row>

    <CallSource>999</CallSource>

    <CallerCityStateZipCode>

    </CallerCityStateZipCode>

    <CallerName>TEST</CallerName>

    <CallerPhone>TEST</CallerPhone>

    </Row>

    <Row>

    <Beat>E27</Beat>

    <MultiEventId>0</MultiEventId>

    <PrimaryUnitId>E09A1</PrimaryUnitId>

    </Row>

    </CommonEventData>'

    SELECT

    MAX(RO.W.value('CallSource[1]','NVARCHAR(50)') ...

    "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: seven digit random number

    You could go with:

    SELECT cast(8999999*rand() as int)+1000000

    For multiple rows you could go with:

    SELECT cast(8999999*rand(cast(newid() AS varbinary)) as int)+1000000

    FROM <something>

    Edit: typo

    "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: Stairway to SQL Server Security: Level 1, Overview of SQL Server Security

    I just read this. Great work Don. Very thorough and a really good read. I am looking forward to the rest of the SQL Server Security stairways!

    "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 with a SQL training question.

    DDL is always helpful for getting a good answer faster.

    Below is the DDL and solution to your problem. Note that some columns are not necessary; I included them so...

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

    I would start with The Microsoft Data Warehouse Toolkit: With SQL Server 2008 R2 and the Microsoft Business Intelligence Toolset.

    Though the book is based on the SQL Server 2008...

    "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 fix the used space of a database?

    ricardo_chicas (5/23/2014)


    HI

    I am using sql server 2008 r2 sp 10

    I have a database that originally consumed 500gb, I truncated most of the tables and now the biggest table consume around...

    "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 accomplish this?

    Please include some DDL next to so as to get a faster response (note the link in my signature for getting help here).

    That said, I think this is what...

    "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: identifying different patterns

    mickyT (5/20/2014)


    Hi

    Here's another method using the same splitter and with the same conditions as Alan's. I though cube may give you the results you need

    declare @string varchar(500) = 'Carborator...

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

    Megha P (5/20/2014)


    Hi..Ed Pollack

    once again thanks..your code works correctly :-).

    meanwhile i come up with below code..just to share

    /* Data generation for #LocalTempTable */

    DECLARE @Date1 datetime

    DECLARE @Date2 datetime

    SET @Date2...

    "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: identifying different patterns

    Using the splitter function referenced in my signature you could do this.

    declare @string varchar(500) = 'Carborator Break Engine Oil';

    declare @tblPattern table (ID INT IDENTITY, Pattern VARCHAR(500), PatternIdentifier INT);

    ;WITH split1 AS...

    "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: Update question on order of tables in join

    davoscollective (5/19/2014)


    Alan.B (5/18/2014)


    Your update query should be fine and, no, it does not matter if you include the table in the FROM or table operator clauses (e.g. JOIN & APPLY)....

    "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: Difference between two dates (Excluding Weekends)

    I did not address the weekend requirement but came up with something that will calculate days, hours and minutes. The only thing left to do is calclulate how much 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: Update question on order of tables in join

    Your update query should be fine and, no, it does not matter if you include the table in the FROM or table operator clauses (e.g. JOIN & APPLY).

    With the...

    "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 seperate the month and year from date?

    Taking it one step further...

    DECLARE @dt DATETIME;

    SET @dt = '2014-04-01';

    SELECT left(DATENAME(month,@dt),3)+'-'+ right(YEAR(@dt),2)

    "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,951 through 1,965 (of 2,462 total)