Forum Replies Created

Viewing 15 posts - 526 through 540 (of 1,082 total)

  • RE: Help to Write one select CURSOR who sum one field in the last recno and put it one actual recno on selected field.

    Try this:

    DECLARE @tmp TABLE

    (id INT IDENTITY(1,1)

    ,fechahora DATETIME

    ,m3salida DECIMAL(15,8))

    INSERT INTO @tmp

    (fechahora,m3salida)

    SELECT '2008-11-17',569512.00 UNION all

    SELECT '2008-11-17',966786.00 UNION all

    SELECT '2008-11-17',465119.00

    SELECT

    [1].ID

    ,[1].fechahora

    ,[1].m3salida

    ,[2].m3salida

    ,[1].m3salida- isnull([2].m3salida,0)

    FROM @tmp [1]

    LEFT JOIN @tmp [2]

    ON [1].id...

    ----------------------------------------------
    Try to learn something about everything and everything about something. - Thomas Henry Huxley

    :w00t:
    Posting Best Practices[/url]
    Numbers / Tally Tables[/url]

    SQL-4-Life
  • RE: Help to Write one select CURSOR who sum one field in the last recno and put it one actual recno on selected field.

    Max this op is using SQL 2000 ROW_NUMBER() won't work

    ----------------------------------------------
    Try to learn something about everything and everything about something. - Thomas Henry Huxley

    :w00t:
    Posting Best Practices[/url]
    Numbers / Tally Tables[/url]

    SQL-4-Life
  • RE: Update Table based on Sum()

    Thanks Jeff,

    Very useful info there 🙂

    ----------------------------------------------
    Try to learn something about everything and everything about something. - Thomas Henry Huxley

    :w00t:
    Posting Best Practices[/url]
    Numbers / Tally Tables[/url]

    SQL-4-Life
  • RE: Search SP Code for Multiple Occurances of Char Strings

    cool,

    Could you post your solution once you find the correct answer or if you need more help let us know.

    thanks

    Chris

    ----------------------------------------------
    Try to learn something about everything and everything about something. - Thomas Henry Huxley

    :w00t:
    Posting Best Practices[/url]
    Numbers / Tally Tables[/url]

    SQL-4-Life
  • RE: SQL Table Variables

    Thanks longobardia,

    I think he found it 2 posts back. I'm trying to get into the habit of helping people who are new to SQL with finding the problems/solutions themselves with...

    ----------------------------------------------
    Try to learn something about everything and everything about something. - Thomas Henry Huxley

    :w00t:
    Posting Best Practices[/url]
    Numbers / Tally Tables[/url]

    SQL-4-Life
  • RE: Search SP Code for Multiple Occurances of Char Strings

    Did this work?

    ----------------------------------------------
    Try to learn something about everything and everything about something. - Thomas Henry Huxley

    :w00t:
    Posting Best Practices[/url]
    Numbers / Tally Tables[/url]

    SQL-4-Life
  • RE: nvarchar vs int :(

    are you saying that the primary key on your table is a nvarchar?

    ----------------------------------------------
    Try to learn something about everything and everything about something. - Thomas Henry Huxley

    :w00t:
    Posting Best Practices[/url]
    Numbers / Tally Tables[/url]

    SQL-4-Life
  • RE: Search SP Code for Multiple Occurances of Char Strings

    this is the first time I've used this table bu maybe something like this:

    SELECT DISTINCT

    p.Name,

    c.Name

    FROM sysdepends d

    INNER JOIN sys.Objects p ON p.Object_ID = d.Id

    INNER JOIN sys.Objects c ON c.Object_ID...

    ----------------------------------------------
    Try to learn something about everything and everything about something. - Thomas Henry Huxley

    :w00t:
    Posting Best Practices[/url]
    Numbers / Tally Tables[/url]

    SQL-4-Life
  • RE: Search SP Code for Multiple Occurances of Char Strings

    Here is some code.

    But this will run like a dog if it's run on all tables/comments

    DECLARE @tbltables TABLE

    ([Name] VARCHAR(10))

    INSERT INTO @tbltables

    SELECT 'Table_A' UNION

    SELECT 'Table_B'

    DECLARE @Comments TABLE

    (Id INT,

    [text] VARCHAR(MAX))

    INSERT INTO @Comments...

    ----------------------------------------------
    Try to learn something about everything and everything about something. - Thomas Henry Huxley

    :w00t:
    Posting Best Practices[/url]
    Numbers / Tally Tables[/url]

    SQL-4-Life
  • RE: insert multiple times...

    IS this working with the change to the insert statement yet?

    ----------------------------------------------
    Try to learn something about everything and everything about something. - Thomas Henry Huxley

    :w00t:
    Posting Best Practices[/url]
    Numbers / Tally Tables[/url]

    SQL-4-Life
  • RE: Displaying NULL as the last row + ORDER BY

    Thanks Jeff,

    Like Jeff has just shown you , it's good to out put you order by so you can see the values.

    The reason you still need to order by the...

    ----------------------------------------------
    Try to learn something about everything and everything about something. - Thomas Henry Huxley

    :w00t:
    Posting Best Practices[/url]
    Numbers / Tally Tables[/url]

    SQL-4-Life
  • RE: SQL Table Variables

    yes but you need to alias in the select part of the query as well otherwise sql doesn't know which table that columns is coming from...

    ----------------------------------------------
    Try to learn something about everything and everything about something. - Thomas Henry Huxley

    :w00t:
    Posting Best Practices[/url]
    Numbers / Tally Tables[/url]

    SQL-4-Life
  • RE: Displaying NULL as the last row + ORDER BY

    so in your example, if the null values get given 5 and the non-nulls get 4 then that shows

    4 comes before 5

    so non-nulls come before nulls.

    does that make sense.

    I...

    ----------------------------------------------
    Try to learn something about everything and everything about something. - Thomas Henry Huxley

    :w00t:
    Posting Best Practices[/url]
    Numbers / Tally Tables[/url]

    SQL-4-Life
  • RE: Displaying NULL as the last row + ORDER BY

    Ok I think you need to realise that it's not sorting but

    column 0 or column 1

    It's sorting by the numbers 0 and 1 which means 0 always comes before 1.

    ----------------------------------------------
    Try to learn something about everything and everything about something. - Thomas Henry Huxley

    :w00t:
    Posting Best Practices[/url]
    Numbers / Tally Tables[/url]

    SQL-4-Life
  • RE: Update Table based on Sum()

    I think you need to a filter on the last table in the nested.

    ----------------------------------------------
    Try to learn something about everything and everything about something. - Thomas Henry Huxley

    :w00t:
    Posting Best Practices[/url]
    Numbers / Tally Tables[/url]

    SQL-4-Life

Viewing 15 posts - 526 through 540 (of 1,082 total)