Viewing 15 posts - 346 through 360 (of 518 total)
This should work, I think..:
DELETE D FROM Table1 AS D
INNER JOIN StoreGroupMember A
ON A.Store_ID = D.Store_ID
WHERE A.StoreNumber = 9833
I think I got the tables right, but it's a bit unclear....
September 15, 2010 at 2:38 pm
WayneS (9/15/2010)
Derrick Smith (9/15/2010)
You mean you want to pull the two most recent orders for each product, sorted by OrderDate, and then display the corresponding OrderNumber, right?
FelixG (9/15/2010)
September 15, 2010 at 2:28 pm
I suppose you could just create a dynamic sql statement to create the database with the company name as a variable, and execute that.
September 15, 2010 at 2:26 pm
Sorry, misunderstood...try this. Will pull the two highest dates for each product, and print their corresponding order number.
;WITH CTE AS (
SELECT ProductCode,
ROW_NUMBER() OVER (PARTITION BY ProductCode ORDER BY OrderDate DESC)...
September 15, 2010 at 2:00 pm
WITH CTE AS (
SELECT ProductCode, MAX(OrderDate) as OrderDate, MAX(OrderNumber) as OrderNumber
FROM Orders
GROUP BY ProductCode
)
SELECT O.ProductCode, cte.OrderDate as [MaxOrderDate], cte.OrderNumber as [MaxOrderNumber]
FROM Orders O
INNER JOIN CTE on CTE.ProductCode = O.ProductCode
I wasn't...
September 15, 2010 at 1:41 pm
edit: there are a few syntax issues with your script, such as cartesian products when you select multiple tables without any join criteria.
Here is a script I've been using for...
September 15, 2010 at 1:28 pm
SELECT distinct MA.Account
, M.DisplayName
, MUA.UserName
, CC.EmailTo
, aspnet_Roles1.RoleName
FROM AfsDepositGateway.dbo.MerchantAccounts MA
INNER JOIN Merchants M ON
M.MerchantId = MA.MerchantId
INNER JOIN MerchantUserAccounts MUA ON
MUA.MerchantId = M.MerchantID
INNER JOIN CustomerContacts CC ON
CC.CustomerContactId = M.CustomerContactId
INNER...
September 15, 2010 at 1:05 pm
Ah crap, I did. Didn't even notice that. Hard to follow the logic of this query..working on it.
September 15, 2010 at 12:59 pm
Unfortunately I'm writing this blind with no real way to quickly check syntax..if you could post table definitions, it would help a bunch.
September 15, 2010 at 12:51 pm
As Mike said, if you create an alias for a table, you need to use that alias for every mention of the table. You can't mix and match. Also, I...
September 15, 2010 at 12:21 pm
Yes, each instance needs its own IP address on a cluster.
Also Yes, having the data files and log files on separate spindles is absolutely the best way to go.
September 15, 2010 at 10:16 am
Whoops - you're doing a cartesian join on your subqueries. It should be an inner join on those 3 fields. Haven't had my coffee yet...will update with a new query...
September 15, 2010 at 8:12 am
Just out of curiosity..have you run a dbcc dbreindex() or alter index rebuild? Also make sure you update statistics with fullscan after creating/dropping/modifying indexes.
September 15, 2010 at 8:05 am
You're missing a comma after the first subquery:
and test_id = kc.test_id),
district_average_percent = (SELECT district_average_percent
If that doesn't resolve it, then you're probably getting more than 1 result from one of the...
September 15, 2010 at 8:02 am
Bhuvnesh (9/15/2010)
Derrick Smith (9/14/2010)
It sounds more like Table 2 is missing indexes or statistics.How did you get this from above first post ( from DBCC results)?
Because there aren't many...
September 15, 2010 at 7:43 am
Viewing 15 posts - 346 through 360 (of 518 total)