Forum Replies Created

Viewing 15 posts - 3,361 through 3,375 (of 3,957 total)

  • RE: Comparison Across Columns

    Understood. A minor modification:

    ;WITH CTE AS (

    SELECT [Length], [Width], [Height]

    ,(SELECT MAX(dim)

    FROM (VALUES ([Length]), ([Width]), ([Height]))...

  • RE: Aggregate Query question

    While I am loathe to quote myself (well, not really, just saying), have you seen this article?

    http://www.sqlservercentral.com/articles/sql+n-Tuples/89809/

    A minor modification to calculate the value of each n-tuple and then select for...

  • RE: How to query and filter a field that mix with text datatype and xml datatype

    Maybe this is too simplistic but couldn't you do something like this?

    create table #Demo (vc varchar(100))

    insert into #Demo (vc)

    select 'King'

    union select 'Queen'

    union select '<Food> Apple </Food>'

    union select 'Teacher'

    union select 'Student'

    union...

  • RE: Query Half hourly meter reading table

    I'd say the design is probably OK for what you're doing.

    I'm concerned about the data getting stored for the reading time. Your sample data is nice and clean, that...

  • RE: Update a 'field' where the 'field' is...

    Post deleted because I mistakenly quoted above instead of editing it. 😀

  • RE: Update a 'field' where the 'field' is...

    Something like this should get you there:

    Update c1

    Set ClientName = 'ZZ ' + convert(nvarchar(max),ClientName)

    FROM Clients c1

    LEFT JOIN Clients c2 ON 'ZZ ' + convert(nvarchar(max),c1.ClientName) = c2.ClientName

    Where ClientTerminationDate Is Not NULL...

  • RE: Comparison Across Columns

    hisakimatama (6/19/2012)Basically, what I need to do is to take the three columns of the table, and compare them against some numbers; specifically, 9, 6.5, and 3. If any...

  • RE: Calculate ABC category

    Last time for tonight I promise. Here's the killer version:

    create table #MyDataTable (ID INT, code char(10), value money, cumtot money, threshold money)

    insert #MyDataTable (ID, code, value)

    select 1, 'PROD1', £600...

  • RE: Calculate ABC category

    Not being one to rest on past accomplishments, I've improved both versions:

    create table #MyDataTable (ID INT, code char(10), value money, cumtot money, threshold money)

    insert #MyDataTable (ID, code, value)

    ...

  • RE: Calculate ABC category

    And in case anybody calls me a one trick pony, here's another way to do it.

    But I do need to warn of the hidden RBAR that you can find explained...

  • RE: unique row id

    Siten0308 (6/19/2012)


    Hello everyone

    thanks dwain for the correction, however I have tried what you have and came up with the same results for example:

    if i do the rowid = row_Number() etc.,...

  • RE: Select Number before "/"

    My guess was right then.

    BTW. I meant the dissection by Cadavre not dissection of Cadavre, in case anyone was wondering. 😀

  • RE: Select Number before "/"

    vinu512 (6/19/2012)


    dwain.c (6/19/2012)


    There's also a PATINDEX solution to this.

    DECLARE @t TABLE (mystring VARCHAR(100))

    INSERT INTO @t

    SELECT '100034/com.ccs.ccscontact'

    UNION ALL SELECT '1003/com.ccs.ccscontact'

    UNION ALL SELECT '100/com.ccs.ccscontact'

    UNION ALL SELECT '20005/com.ccs.ccscontact'

    SELECT SUBSTRING(mystring, 1, PATINDEX('%[^0-9]%', mystring)-1)

    FROM @t

    Just...

  • RE: Calculate ABC category

    Kelvin Phayre (6/19/2012)


    Absolutely brilliant solution.

    Fits my requirement's 100%.

    Many thanks.

    Well thank you kind Sir Kelvin!

    You do need to be careful about a couple of things though:

    1. If you are doing this...

  • RE: Old and new in same column

    Easy, peasy!

    Just for fun, I'm going to take the OP's formatting literally.

    DECLARE @team table (emp_code int,old_emp_code int, emp_name varchar(20))

    insert into @team (emp_code,old_emp_code, emp_name)

    select 1, 100,'ABA' UNION ALL select 2, 200,'ABB'...

Viewing 15 posts - 3,361 through 3,375 (of 3,957 total)