Forum Replies Created

Viewing 15 posts - 76 through 90 (of 921 total)

  • RE: Geting negative and positive value

    SELECT Goods, SUM(Quantity) Both, SUM(CASE WHEN Quantity > 0 THEN Quantity END) Pos, SUM(CASE WHEN Quantity < 0 THEN Quantity END) Neg

    FROM Table

    GROUP BY Goods

    ORDER BY Goods, Both



    --Jonathan

  • RE: do I have to DELETE then re-enter

    The method depends upon whether and how you have used DRI...

    If, as your "schema" pseudocode implies, you have not used DRI, you can just use UPDATE statements on each table. ...



    --Jonathan

  • RE: recompile objects

    There are no "on-disk compiled versions of the stored procedures."



    --Jonathan

  • RE: recompile objects

    No, but you could try something like this:

    DECLARE @v-2 nvarchar(258)

    DECLARE ViewCur CURSOR FOR

    SELECT QUOTENAME(Table_Schema + '.' + Table_Name)

    FROM INFORMATION_SCHEMA.VIEWS

    OPEN ViewCur

    FETCH NEXT FROM ViewCur INTO @v-2

    WHILE @@FETCH_STATUS = 0

    BEGIN

     EXEC('EXEC sp_refreshview '...



    --Jonathan

  • RE: databaseid

    SELECT DB_NAME(database_id)



    --Jonathan

  • RE: Help with date conversion

    declare @t datetime, @h char(4)

    set @t = '20040702'

    set @h = '0800'

    select @t, @t + STUFF(@h,3,0,':')



    --Jonathan

  • RE: Sum Aggregate

    GROUP BY CONVERT(char(6),DateField,112)



    --Jonathan

  • RE: recompile objects

    All objects?  DBCC FREEPROCCACHE



    --Jonathan

  • RE: how to archive an inventory

    Sorry, I guess that's jargon. 

    OLTP is OnLine Transaction Processing and DSS is Decision Support System.  Although I think the term DSS is now...



    --Jonathan

  • RE: DateTime Function

    A UDF will both perform worse and cause the maintenance programmer to deal with another object.  I see nothing wrong with the readablity of the OP's solution, and that's the reason...



    --Jonathan

  • RE: how to archive an inventory

    The way I usually do this in an OLTP system by creating an inventory transaction table.  That way one can ascertain inventory balances at any point, plus you have the added...



    --Jonathan

  • RE: Delete records from a "summarized" table.

    DELETE p

    FROM Prod p JOIN Audit a ON p.UserID = a.UserID AND p.EventID = a.EventID AND p.Event_Date = a.Orig_Event_Date



    --Jonathan

  • RE: Query problem for a non DBA

    You could use the SUM() aggregate function along with a CASE expression:

    SUM(CASE WHEN Pupil_Details.LeaveDate BETWEEN @StartDate AND @EndDate THEN 1 END) AS 'LeaverCount'



    --Jonathan

  • RE: Eliminating duplicate records in join

    Actually, that doesn't help much.  That could (with some nasty manual reformatting) be turned into sample data, but we (well, I, anyway) need more than just that.  Script out and...



    --Jonathan

Viewing 15 posts - 76 through 90 (of 921 total)