Forum Replies Created

Viewing 15 posts - 4,291 through 4,305 (of 6,036 total)

  • RE: How to avoid Subquery

    Jeff,

    select * from TableA

    where TransactionDate NOT between dateadd(dd , -90 , getdate()) and getdate()

    will be even more faster, but I believe TableB was mentioned in original query on purpose.

    Your...

  • RE: How to avoid Subquery

    select * from TableA

    LEFT join TableB b on a.ID= b.ID AND (a.TransactionDate between dateadd(dd , -90 , getdate()) and getdate())

    WHERE B.ID IS NULL

    I'm sure you have clustered index on column...

  • RE: Set SysProcesses.Program_Name from OSQL or T-SQL?

    Happy to help you out of that tree.

    Did not mention SPID because it's too obvious for such old wolves

  • RE: What am I missing?

    No, you've got it wrong.

    Result of your expression is REAL.

    As I understand it must be DECIMAL(12,1)

    So, you need to do this:

    CAST(CAST(@n AS FLOAT) / @p AS DECIMAL(12,1))

    Check it out for...

  • RE: What am I missing?

    You are missing order of operations.

    1) you do division. You divide int by int, result is int (see BOL) = 0

    2) you do conversion of the division result to DECIMAL(12,1)...

  • RE: Set SysProcesses.Program_Name from OSQL or T-SQL?

    Will this work for you?

    Does not modify sysprocesses but lets you catch user defined name and associate it with whatever security context you deal with.

    Create table "SomeTable" in pubs on...

  • RE: How to find usused indexes in any database ?

    You don't need full workload.

    You need only indexes used during selects.

    What kind of script will tell you which keys on you keyboard are unused?

    You need to see all texts you...

  • RE: How to find usused indexes in any database ?

    Start Profiler.

  • RE: Proc calling Proc

    I would create table function instead of second procedure.

    But if you insist on having SP do this:

    INSERT INTO #Resultset (... columns list ...)

    EXEC dbo.ReportSP (@Month, @Year)

  • RE: Is the following line ok?

    Actually there is a point to specify object type.

    If you check for table existence OBJECT_ID will bring you valid ID and you could end up trying insert something into non-updateable...

  • RE: Get percentages

    Yes, saving a CASE is nice thing, but I would prefer to use one CASE instead of repeating query to the same table:

    SELECT COUNT(case when PLtat + PLunworkable > 75...

  • RE: Is the following line ok?

    OBJECT_ID('dbo.Result','U') does not work in SQL2000.

    Did not try it in 2k yet.

  • RE: Is the following line ok?

    I would prefer to use system functions:

    IF OBJECTPROPERTY (Object_ID('Result'), 'IsUserTable')= 1 and OBJECTPROPERTY (Object_ID('Time_definition'), 'IsUserTable') = 1

    BEGIN

    Your query will include views as well.

    You need to add "AND TABLE_TYPE =...

  • RE: OSQL output stored procedure column formatting problem

    I can assure you: it's 100% not right.

    I lost count of my reports created using bcp. And only case when I've got pads is when I've got CHAR or NCHAR...

  • RE: OSQL output stored procedure column formatting problem

    What you get is a result of SP execution.

    In order to change that result you need change SP.

    If you cannot change this SP then create another one which will be...

Viewing 15 posts - 4,291 through 4,305 (of 6,036 total)