Forum Replies Created

Viewing 15 posts - 14,746 through 14,760 (of 14,953 total)

  • RE: Append timestamp with date to tablename using select into

    Add a column to the table like this:

    alter table dbo.Table

    add InsertedOn datetime default(getdate())

    Then it will automatically put the date and time (down to +/-3 milliseconds) in each row.

    If you don't...

  • RE: need help with this query please?

    Alter table dbo.Sales

    add TransactionID int identity, RefundID int null references dbo.Sales(transactionid)

    create index IDX_SalesRefunds on dbo.sales (refundid)

    create index IDX_SalesTransactions on dbo.sales(transactionid)

    create index IDX_SalesSale on dbo.sales(description, amount, date, transactionid)

    update dbo.sales

    set refundid =...

  • RE: Query that Returns Month to Date and YTD in Same Record

    You'll need to run them separately, then combine them in a final query.

    Perhaps something like:

    ;with

    Daily (DAcctCode, TotalDailyRevenue, DDay, DMonth, DYear) as

    (select AcctCode,

    isnull(sum(FuelFee), 0)

    + isnull(sum(CashFee), 0)

    + isnull(sum(ScFee), 0),

    datepart(day,...

  • RE: Top N plus

    Ranking the whole result set is probably your only option.

    One last idea, have you tried:

    select top 5 ...

    from ...

    order by ranking desc

    union

    select ...

    from ...

    where product = @param

    So the first query...

  • RE: Top N plus

    My suggestion is either use Analysis Services to pre-aggregate the most common queries, or do so yourself in a separate Reporting database.

    Are you querying on up-to-the-second data? Or would...

  • RE: I am so depressed after I work on Question of the Day

    And research skills are at LEAST 50% of the job. Probably much, much more than that.

  • RE: selecting top N records by type

    Congrats on the cert! (I may one day get some certs myself. Haven't been able to afford it yet.)

  • RE: New Server - do I go for RAID 10?

    Separating them will usually improve performance.

    If you really want to go whole hog, separate it one step further and put your non-clustered indexes on a separate drive. That'll usually...

  • RE: selecting top N records by type

    Also, since SQL 2000 doesn't allow the use of a variable in the TOP clause, a ranked temp table will add that functionality. The subquery has to have "top...

  • RE: selecting top N records by type

    toniupstny (2/1/2008)


    GSquared. Can you please provide the preferred alternate to a correlated subquery?

    Thanks

    Toni

    Insert into a temp table, add rankings to it, select from that.

    The correlated subquery will be...

  • RE: Multi-part identifier "table.column" could not be bound.

    The other thing you could try is making sure the domain of the tables is included in the query. Not sure if that'll matter in your case, but I've...

  • RE: selecting top N records by type

    Keep in mind that the suggested solution (a correlated subquery) is very resource hungry and will be quite slow on a big table with a lot of different values in...

  • RE: I am so depressed after I work on Question of the Day

    Don't let the question of the day get you down. Use it as a learning tool. Also, understand that many of the questions are designed to be tricks,...

  • RE: Table Variables

    srienstr (1/31/2008)


    GSquared (1/31/2008)


    I disagree with the point about the transactions.

    Dictionary definition of "valid": "well based or logical" (Compact Oxford English Dictionary, as referenced on http://www.onelook.com).

    Doing a transaction and rollback on...

  • RE: zero tables

    Are you trying to find out which tables in a database have 0 rows? (Not sure from the wording of your question.)

Viewing 15 posts - 14,746 through 14,760 (of 14,953 total)