Forum Replies Created

Viewing 12 posts - 1 through 12 (of 12 total)

  • RE: Creating XML using Tsql

    Is it possible to redefine the XML schema and do without the elements ColorWhite, ColorBlack, etc?

    If so, some version of the following simplified SQL could apply:

    select

    a.AccountNo as "Account/AccountNo"

    ...

  • RE: Creating XML using Tsql

    The following may be a good starting point for the desired results. NOTE: You may want to create portions of this SQL dynamically if there are many different colors to...

  • RE: Self Join

    You could use a SUM Window function as an alternative...

    select

    TranCode

    ,TranDescription

    ,TranDescription

    ,sum(TranAmount) over (partition by TranCode) as TranCodeTotal

    from @transactions

    order by TranCode

  • RE: Split the values from ('1,2,3,4') to ('1','2','3','4') or (1,2,3,4)

    In SS2005, the following may be another possibility:

    select * from emp where empid in

    ( select i.value('text()[1]','int')

    from (select cast('<i>'+replace(@str,',','</i><i>')+'</i>' as xml) as xlist) s

    cross apply s.xlist.nodes('/i') X(I)

    )

  • RE: Uniqueidentifier.

    As a quick proof of concept, you could start with something like...

    select cast(newid() as sysname)

    -- OR --

    print cast(newid() as sysname)

  • RE: help with multi-path hierarchical data

    If I understand the expected results correctly, the following would be a possible solution using an rCTE:

    declare @StartDevice varchar(32) ,@EndDevice varchar(32);

    select @StartDevice = 'G9' ,@EndDevice = 'BIN200';

    ;with cte as

    (

    ...

  • RE: Sql query help

    Could you use results returned from the following?

    SELECT

    StaffId

    ,ClientId

    ,MIN(Date) AS FirstDate

    ,MAX(Date) AS LastDate

    ,DATEDIFF(ww ,MIN(VisDate) ,MAX(VisDate)) as Weeks

    FROM [dbo].[Visits]

    GROUP BY StaffId ,ClientId

  • RE: How to disable output of crusors

    If you FETCH INTO a @BusinessEntityID variable, SSMS will not display anything by default:

    BEGIN

    SET XACT_ABORT ON

    SET NOCOUNT ON

    DECLARE @BusinessEntityID INT -- Or VARCHAR(128), Perhaps?

    ...

  • RE: How to Eliminate loop and use set based approach?

    I think this could be accomplished with an rCTE in SQL.

  • RE: Returning all members of the group for a given member

    Would something like the following be useful?

    DECLARE @t TABLE

    (

    Node int null

    ,Parent int null

    );

    INSERT @t (Node ,Parent)

    SELECT 1 ,null UNION ALL

    SELECT 2 ,1...

  • RE: Problem when using parameter in XQuery Value method

    sql:variable cannot be used for an XPath expression - it's really a bind variable for specific XML element or attribute values.

    However, what if you created some dynamic SQL with the...

  • RE: Starting with "WITH"

    Suckishly? ¿Por qué? I've seen otherwise, but, I'm curious to know the instances where CTEs have performed poorly. Are you working in a data warehouse environment? ...

Viewing 12 posts - 1 through 12 (of 12 total)