Viewing 15 posts - 451 through 465 (of 699 total)
You're right, I can't know for sure. But the query he was using was so basic that I'd find it hard to believe that anything else was the reason.
July 13, 2011 at 12:47 pm
Another important thing to consider is just how normalized your tables are in your database.
I can't tell you how many times I've worked with databases in which there is a...
July 12, 2011 at 2:43 pm
I'd bet your biggest issue with this query is simply that there is a large amount of data present, and no indexes to handle them.
Create an index with username, cust_id,...
July 12, 2011 at 1:29 pm
Incase you're curious about the XML solution, you could try something like
DECLARE @Message VARCHAR(MAX)
DECLARE @ResultsTable TABLE
(
ID INT IDENTITY PRIMARY KEY,
[Message] VARCHAR(MAX)
)
INSERT INTO @ResultsTable ([Message])
VALUES ('This is a message')
INSERT INTO @ResultsTable...
July 12, 2011 at 1:21 pm
The only drawback to my solution is that, I *think*, there may be a limit to how much can fit into that @Message variable, even though it is a VARCHAR(MAX)...
July 12, 2011 at 12:59 pm
Something like this maybe? Adapted to fit your needs of course, but I think this should work.
DECLARE @Message VARCHAR(MAX)
DECLARE @ResultsTable TABLE
(
ID INT IDENTITY PRIMARY KEY,
[Message] VARCHAR(MAX)
)
INSERT INTO @ResultsTable ([Message])
VALUES ('This...
July 12, 2011 at 12:53 pm
Try something like this. You're doing two seperate calculations, might be better to split them.
DECLARE @TotalAllPaidAmount INT
DECLARE @TotalAllCustomers INT
DECLARE @TotalTransactions INT
SELECT @TotalAllPaidAmount = SUM(paid_amount), @TotalAllCustomers = COUNT(DISTINCT(customer_id)), @TotalTransactions = COUNT(*)
FROM...
July 12, 2011 at 11:29 am
Hah - I completely forgot I was looking at the SQL Server 2008 forums. Of course MERGE is much better for UPSERT procedures 😛 my bad! Don't have enough experience...
July 12, 2011 at 9:29 am
Would this work?
-- EXISTS IN TABLE B
UPDATE A
SET A.model = B.model,
A.speed = B.speed
FROM TableA A
JOIN TableB B ON A.machine_id = TableB.machine_id
-- EXISTS IN TABLE C
UPDATE A
SET A.model = C.model,
A.speed =...
July 12, 2011 at 9:12 am
Without more data its hard to answer your question, but from what I can gather, you're trying to do an UPSERT basically. IE, insert data into Table A if it...
July 12, 2011 at 8:48 am
if you're more of a visual person, you might want to consider looking into SQL Server Integration Services. In SQL Server 2005, this can be found in the Business Intelligence...
July 12, 2011 at 8:41 am
Oh? cool, didn't know that. But does the transaction remain open only for the current session in question? IE, if you were using SSMS, and you began a transaction which...
July 12, 2011 at 8:26 am
One thing you can also do is something like:
CREATE TABLE #Test
(
ID INT IDENTITY PRIMARY KEY,
ID2 INT
)
INSERT INTO #Test (ID2)
SELECT 1
UNION ALL
SELECT 2
UNION ALL
SELECT 3
UNION ALL
SELECT 4
UNION ALL
SELECT 5
UNION ALL
SELECT 6
UNION...
July 12, 2011 at 7:34 am
Yeah I'd agree with the DECIMAL value. I'm assuming its a typo, but you used SET instead of SELECT in your second statement. It should read:
SELECT @Result1 = (SELECT ROUND(MAX(Value),1)
FROM...
July 12, 2011 at 7:14 am
Viewing 15 posts - 451 through 465 (of 699 total)