Forum Replies Created

Viewing 15 posts - 451 through 465 (of 699 total)

  • RE: T_SQL Performance Issue

    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.

  • RE: Capacity Planning for Databases

    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...

  • RE: T_SQL Performance Issue

    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,...

  • RE: Multiple values in a variable.

    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...

  • RE: Multiple values in a variable.

    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)...

  • RE: Multiple values in a variable.

    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...

  • RE: Need help optimizing the performance of a query

    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...

  • RE: Update table using 2 other tables

    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...

  • RE: Update table using 2 other tables

    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 =...

  • RE: Update table using 2 other tables

    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...

  • RE: Some guidance if you could

    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...

  • RE: delete without commit

    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...

  • RE: delete without commit

    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...

  • RE: Need error explanation for query, PLEASE

    Oops. Right. I knew that 😡

  • RE: Need error explanation for query, PLEASE

    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...

Viewing 15 posts - 451 through 465 (of 699 total)