Forum Replies Created

Viewing 15 posts - 1,696 through 1,710 (of 7,619 total)

  • Reply To: T-SQL code help

     

    SELECT
    m.A AS original_currency, m.B AS posting_currency,
    /*...,*/
    m.value AS original_value,
    COALESCE(m.value * cc.conversion_rate...

    SQL DBA,SQL Server MVP(07, 08, 09) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".

  • Reply To: T-SQL code help

    You will also need the date (at least), since currency conversion values change over time.

    SQL DBA,SQL Server MVP(07, 08, 09) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".

  • Reply To: Problem using While to loop from record

    luissantos wrote:

    Hy Scott,

    Thanks for your reply and useful advises, but what kind of filter i must put in the Where condition inside the Begin ?

    i think that the field dostamp...

    SQL DBA,SQL Server MVP(07, 08, 09) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".

  • Reply To: Problem using While to loop from record

    You don't have any WHERE condition in the SELECT in the loop.  Thus, so it's essentially random which row SQL will return.

    Btw, don't use functions against table columns in the...

    SQL DBA,SQL Server MVP(07, 08, 09) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".

  • Reply To: Top 1 makes very fast query into very slow query

    pdanes wrote:

    The Dixie Flatline wrote:

    Yes.    Eirikur's version of DelimitedSplit8k is fast AND is an inline table valued function.   Everyone who can't use String_Split should get a copy.   Also, use of an...

    SQL DBA,SQL Server MVP(07, 08, 09) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".

  • Reply To: Top 1 makes very fast query into very slow query

    Yes, in theory could be less efficient in some cases than a LOOP join.  But it's still reasonable performance.  You'll never totally drop off a performance cliff going from LOOP...

    SQL DBA,SQL Server MVP(07, 08, 09) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".

  • Reply To: Help with a query

    First let's correct the PK.  Then the code for the proc.

    ALTER TABLE [dbo].[Contracte] DROP CONSTRAINT [PK_Contracte];
    ALTER TABLE [dbo].[Contracte] ADD CONSTRAINT [PK_Contracte]
    PRIMARY KEY...

    SQL DBA,SQL Server MVP(07, 08, 09) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".

  • Reply To: Top 1 makes very fast query into very slow query

    If it could ever have more than one, then it needs to be a JOIN, just like you have it.

    SQL DBA,SQL Server MVP(07, 08, 09) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".

  • Reply To: Top 1 makes very fast query into very slow query

    Yeah, seems like a bug in SQL optimizer.  I'd make sure SQL didn't use a LOOP join (gack!) for the two main tables.  I think the hint will also force...

    SQL DBA,SQL Server MVP(07, 08, 09) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".

  • Reply To: Entry point in sysdatabases

    You're welcome!

    SQL DBA,SQL Server MVP(07, 08, 09) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".

  • Reply To: How to troubleshoot PK Constraint violation

    The source table, DBSource.dbo.Contacts, must have duplicate entries for the same ContactID.

    SQL DBA,SQL Server MVP(07, 08, 09) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".

  • Reply To: What is the best way to see Deadlocks info and take advantage of analyzing it?

    Yes, a standard Agent Alert, like below, but you need to change <instance name> to your actual instance name and the job id to your actual job id:

    SQL DBA,SQL Server MVP(07, 08, 09) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".

  • Reply To: What is the best way to see Deadlocks info and take advantage of analyzing it?

    Overhead.  The default health trace contains deadlock info, although I prefer to create my own extended event specifically for deadlocks.

    I have an alert that triggers a job when a deadlock...

    SQL DBA,SQL Server MVP(07, 08, 09) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".

  • Reply To: SQL Query issues - different conditions in the SELECT list

    There is a T-SQL forum.  This type of q would generally go there.  But not a real problem.  Try the code below:

    SELECT pf.Name, 
    ...

    SQL DBA,SQL Server MVP(07, 08, 09) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".

  • Reply To: Huge size of Reporting tables

    Sergiy wrote:

    S_Kumar_S wrote:

    For choice of clustered index columns, I am confident that they are correct. They are int or bigint columns and are very frequently used in many queries.

    on...

    SQL DBA,SQL Server MVP(07, 08, 09) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".

  • Viewing 15 posts - 1,696 through 1,710 (of 7,619 total)