Viewing 15 posts - 14,746 through 14,760 (of 14,953 total)
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...
February 5, 2008 at 11:51 am
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 =...
February 5, 2008 at 11:43 am
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,...
February 4, 2008 at 3:04 pm
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...
February 4, 2008 at 2:49 pm
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...
February 4, 2008 at 1:45 pm
And research skills are at LEAST 50% of the job. Probably much, much more than that.
February 4, 2008 at 11:01 am
Congrats on the cert! (I may one day get some certs myself. Haven't been able to afford it yet.)
February 4, 2008 at 10:59 am
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...
February 4, 2008 at 8:34 am
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...
February 1, 2008 at 12:44 pm
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...
February 1, 2008 at 12:42 pm
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...
February 1, 2008 at 12:36 pm
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...
February 1, 2008 at 7:48 am
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,...
February 1, 2008 at 7:19 am
srienstr (1/31/2008)
GSquared (1/31/2008)
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...
January 31, 2008 at 2:33 pm
Are you trying to find out which tables in a database have 0 rows? (Not sure from the wording of your question.)
January 31, 2008 at 2:24 pm
Viewing 15 posts - 14,746 through 14,760 (of 14,953 total)