Forum Replies Created

Viewing 15 posts - 511 through 525 (of 1,082 total)

  • RE: Use views in Stored Procedures

    You could also just call your procedure and insert it into a table variable or temp table from your main procedure, that way you don't have to create the functions....

    ----------------------------------------------
    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: Arithmetic overflow error converting numeric to data type numeric.

    of the 16 values in your numeric number 9 are keep for the right hand side of the decimal, meaning that only 7 digits can be used on the right...

    ----------------------------------------------
    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: How to reset identity count in sql tables?

    good point.

    Just case someone wants to Use CHECKIDENT.

    Other method of doing it is to

    DBCC CHECKIDENT(mytable,reseed,0)

    --seed it to 0 first

    DBCC CHECKIDENT(mytable,reseed)

    --This will automatically reseed to the next correct seed value.

    Using...

    ----------------------------------------------
    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: ISNULL QUESTION

    Ok the first thing to remember is that they both perform different functions

    Lets start with ISNULL statement

    WHERE ISNULL(Col1,'') = 'NOCHANGE'

    The reason you use is null is so that you don't...

    ----------------------------------------------
    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: Finding record based on the datediff on next record in table

    will this work for you?

    DECLARE @visit TABLE

    (VisitID INT PRIMARY KEY,

    StudentID INT,

    visitDate DATETIME,

    score INT)

    INSERT INTO @visit(VisitID, StudentID,visitDate,score)

    SELECT 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: Data Manipulation

    I would suggest using a tally table rather than a loop 🙂

    ----------------------------------------------
    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: ISNULL QUESTION

    basically if OP2.Contract_Line_Number != 'NOCHANGE'

    Then you will get results

    ----------------------------------------------
    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: select 21/(datediff(dd,getdate(),getdate())

    Is that the solution you using or the problem you having?

    We still don't understand why you feel the need to test GETDATE vs GETDATE cause the answer is ALWAYS 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: select 21/(datediff(dd,getdate(),getdate())

    Or is the situation something like this

    DECLARE @TABLE TABLE

    (Number INT,

    Date1 DATETIME,

    Date2 DATETIME)

    INSERT INTO @TABLE

    SELECT 21,GETDATE(),GETDATE() UNION ALL

    SELECT 21,GETDATE(),DATEADD(dd,2,GETDATE())

    SELECT Number/CASE WHEN (datediff(dd,Date1,Date2)) = 0 THEN 1 ELSE (datediff(dd,Date1,Date2)) END

    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: select 21/(datediff(dd,getdate(),getdate())

    Is this a real life example.

    Cause if you always doing a date diff with GETDATE vs GETDATE then why don't you just do this.

    SELECT 21

    I think something is missing here.

    Do...

    ----------------------------------------------
    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: Poor performing SP

    I agree with all that steve has said,

    I'd just like to add that I see a INDEX hint?

    It's not often that the optimizer is wrong, so make sure the hint...

    ----------------------------------------------
    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: Query Plan's

    thanks for that I didn't know that.

    I'm actually using a real table but my join is using a variable.

    So there is Predicate his using a scalar operator.

    Will this result in...

    ----------------------------------------------
    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.

    I'm not sure what you mean...

    What should the actual results be?

    ----------------------------------------------
    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.

    You can't use ROW_NUMBER() in SQL 2000 or SQL 7 you need to use another approach.

    Try my solution or try reading lynn's post about running totals!

    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: nvarchar vs int

    HI all,

    This is a double post.

    arluna as Jeff and some others mentioned in your other post.

    This shouldn't be a problem, and it's best to make sure your column is indexed.

    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

Viewing 15 posts - 511 through 525 (of 1,082 total)