Forum Replies Created

Viewing 15 posts - 1,126 through 1,140 (of 1,439 total)

  • RE: Row Count

    with cte as (select *,Row_number() over(order by id) as rownumber,

    count(*) over() as total from TableName)

    select * from cte where rownumber between some integers

  • RE: need help with Recusive CTE

    with cte as (

    select CatID as RootCatID,CatID,NumOfProducts

    from Hirarchy

    union all

    select c.RootCatID,h.CatID,h.NumOfProducts

    from Hirarchy h

    inner join cte c on c.CatID=h.ParentID

    )

    select RootCatID,sum(NumOfProducts) as NumOfProducts

    from cte

    group by RootCatID

  • RE: need help with Recusive CTE

    Try this

    declare @CatID int

    --set @CatID=1;

    set @CatID=5;

    with cte as (

    select CatID,NumOfProducts

    from Hirarchy

    where CatID=@CatID

    union all

    select h.CatID,h.NumOfProducts

    from Hirarchy h

    inner join cte c on c.CatID=h.ParentID

    )

    select sum(NumOfProducts) as NumOfProducts

    from cte

  • RE: SQL Query Help

    select Col1,

    case when len(Col1)>10 then Col1 end as Note

    from T

  • RE: sp_executesql with XML not working

    For the case where @var is an int, change

    DTS:Property[@var]

    to

    DTS:Property[sql:variable("@var")]

  • RE: Rounding a number

    Use ROUND

    declare @MinValue decimal(10,5)

    declare @MaxValue decimal(10,5)

    declare @DecimalPlaces int

    set @MinValue = 0.8230

    set @MaxValue = 100.8811

    --set @DecimalPlaces = 0

    --set @DecimalPlaces = 1

    set @DecimalPlaces = 2

    select round(@MinValue,@DecimalPlaces,1)

    select round(@MaxValue,@DecimalPlaces,1)

  • RE: extract XML values from multilanguage xml string storage

    Try this, no extra TEXT elements

    declare @xml as xml

    set @xml = '

    Somevalue1

    somevalue2

    somevalue3

    '

    DECLARE @language VARCHAR(4)

    SET @language = '1023'

    SELECT r.value('.','varchar(100)') AS Value

    FROM @xml.nodes('/TRANSLATIONS/TRANSLATION[@language=sql:variable("@language")]')...

  • RE: extract XML values from multilanguage xml string storage

    No need for dynamic SQL

    DECLARE @language VARCHAR(4)

    SET @language = '1023'

    SELECT r.value('.','varchar(100)') AS Value

    FROM @xml.nodes('/TRANSLATIONS/TRANSLATION[@language=sql:variable("@language")]/TEXT') AS x(r)

    Also the XML isn't valid, the attributes are missing double quotes

  • RE: CHARINDEX counting problem

    Missing a '+7' ??

    i.e.

    SELECT charindex(' ',@string,charindex('view = ',@string)+7)- charindex('view = ',@string)

    should be

    SELECT charindex(' ',@string,charindex('view = ',@string)+7)- (charindex('view = ',@string)+7)

  • RE: Recursive select Query

    It will sort by the Employees name only within a level of the hierarchy. If you have a specific sorting requirement can you post it?

  • RE: query to retreive data containg '_'

    Can you supply some sample data? This appears to work

    declare @General_Info table(first_name varchar(10))

    insert into @General_Info(first_name)

    select 'o_corner' union all

    select 'other' union all

    select 'x'

    select * from @General_Info where first_name like 'o!_%' escape...

  • RE: query to retreive data containg '_'

    Use 'escape'

    select * from General_Info where first_name like 'o!_%' escape '!'

  • RE: Recursive select Query

    ta.bu.shi.da.yu (5/13/2009)


    Atif Sheikh (5/12/2009)


    Hey... I tried that. Doesn't work if F reports to B.

    To Who...?

    Er... sorry. Got that badly wrong. Doesn't work if B reports to F.

    So who...

  • RE: Recursive select Query

    See if this helps

    CREATE TABLE #Employees(Employee CHAR(1) NOT NULL PRIMARY KEY, ReportsTo CHAR(1))

    INSERT INTO #Employees(Employee, ReportsTo)

    SELECT 'A',NULL UNION ALL

    SELECT 'B','A' UNION ALL

    SELECT 'C','A' UNION ALL

    SELECT 'D','C' UNION...

  • RE: Performance issue with tally solution

    RBarryYoung (5/11/2009)


    Paul White (5/10/2009)


    ...

    It's a very fast method - the only disappointment for me was that it is limited to processing text files. Text file bulk import is fast...

Viewing 15 posts - 1,126 through 1,140 (of 1,439 total)