Forum Replies Created

Viewing 15 posts - 1,261 through 1,275 (of 1,438 total)

  • RE: How to retrieve data from ntext (xml) data

    You can get one row per parameter using this

    with cte as (

    select cast(Parameter as xml) as Parameter

    from [dbo].[Catalog])

    select r.value('Prompt[1]','varchar(10)') as ParameterName,

    (select rv.value('.','varchar(10)') as...

  • RE: How to retrieve data from ntext (xml) data

    with cte as (

    select cast(Parameter as xml) as Parameter

    from [dbo].[Catalog])

    select r.value('Prompt[1]','varchar(10)') as ParameterName,

    rv.value('.','varchar(10)') as DefaultValues,

    rd.value('.','varchar(10)') as...

  • RE: How to retrieve data from ntext (xml) data

    declare @x xml

    set @x='..your xml here..'

    select r.value('Prompt[1]','varchar(10)') as ParameterName,

    rv.value('.','varchar(10)') as DefaultValues,

    rd.value('.','varchar(10)') as Dependencies

    from @x.nodes('/Parameters/Parameter') as x(r)

    outer...

  • RE: Selecting records on condition that others exist.

    with cte as (

    select CustomerNumber, PolicyNumber ,StartDate , Premium , EndDate,

    count(*) over(partition by CustomerNumber) as cn

    from mytable)

    select sum(Premium) as [sum for all policies],

    ...

  • RE: Display time clock data in daily columns.

    WITH CTE AS (

    SELECT EmpNum,ClockInDate,ClockInTime,ClockOutTime,

    ROW_NUMBER() OVER(PARTITION BY EmpNum,DATEPART (dw,ClockInDate) ORDER BY ClockInDate) AS rn

    FROM @TimeClock)

    SELECT EmpNum

    ...

  • RE: Help with shredding xml using nodes()

    Not sure how you can get one row per /root tag where there are

    multiple tbl_Component and tbl_Insert child elements, however this may help

    SELECT XMLTable.XMLColumn.value('tbl_Site[1]', 'VARCHAR(25)') AS tbl_Site,

    XMLTable.XMLColumn.value('tbl_Applications[1]', 'VARCHAR(25)') AS...

  • RE: Split a date-range into periods

    You'll need a calendar table with month start and end dates

    if object_id('tempdb..#Calendar') is not null

    drop table #Calendar

    Create table #Calendar(dtStart DateTime,dtEnd as dateadd(day,-1,dateadd(month,1,dtStart)))

    insert...

  • RE: Multiple sumations - at present we perform them sequentially

    Select sum (case when (CPP.Service like 'rrp%' or CPP.Service like 'rrv%' or CPP.Service like 'rrsc' or CPP.Service like 'rrsc') then CPP.PhaseValue - (CPP.PhaseIPT + CPP.Supplier1Charge + CPP.Supplier2Charge) end) as...

  • RE: Multiple sumations - at present we perform them sequentially

    Something like this

    Select sum (case when CPP.Service like 'ci%' then CPP.PhaseValue - (CPP.PhaseIPT + CPP.Supplier1Charge + CPP.Supplier2Charge) end) as [ci_sum],

    ...

  • RE: Selecting more recent child record with parent

    WITH VersionsRn AS (

    SELECT *,ROW_NUMBER() OVER(PARTITION BY Item_Ref ORDER BY Ref DESC) AS Rn

    FROM Versions)

    SELECT i.*,v.*

    FROM Items i

    INNER JOIN VersionsRn v ON v.Item_Ref=i.Ref AND v.Rn=1

  • RE: XML

    select r.value('number[1]','decimal(10,3)') as Sample2Value

    from SampleXML

    cross apply Data.nodes('/wddxPacket/data/struct/var/struct/var[@name="Sample2"]') as x(r)

  • RE: Query Extented Properties Of Tables/Views

    I think

    sys.all_objects.name = 'dbo.tblEXTRACT_RecoveriesClient'

    should be

    sys.all_objects.name = 'tblEXTRACT_RecoveriesClient'

  • RE: Query Extented Properties Of Tables/Views

    change

    sys.tables.name = 'Table 2'

    to

    sys.all_objects.name = 'Table 2' and sys.all_objects.type='U'

  • RE: How to know the name of the SP that is executed

    SELECT OBJECT_NAME(@@PROCID)

  • RE: Help with Update Query

    Maybe this?

    select a.FEILD1,a.LEVEL1,a.SCORE,a.Rank,

    (select b.Rank as "text()"

    from mytable b

    ...

Viewing 15 posts - 1,261 through 1,275 (of 1,438 total)