Forum Replies Created

Viewing 15 posts - 4,981 through 4,995 (of 7,613 total)

  • RE: How to improve that query?

    Yep. Just add the schema to the table and add the other column to the WHERE:

    ...

    FROM dbo.Orders

    WHERE STATUS IN (1, 2, 3) AND Type IN (3, 4)

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

  • RE: Creating an index including non-key columns

    Also, the initial tuning must focus first on getting the best clustered index for every table. Only after that should you create or modify nonclustered indexes.

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

  • RE: Does GROUP BY speed up query on data that is already at lowest granularity?

    Would have to see the actual queries and query plans to really be able to analyze this.

    Also, clock time can be affected by many things. Be sure to review...

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

  • RE: Trigger to show which stored proc has updated a table

    You can use CONTEXT_INFO to pass the name of the proc to the trigger. The calling proc sets specific bytes in CONTEXT_INFO, and the trigger substrings out those bytes...

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

  • RE: Help Converting query -- Do I need a cursor?

    Sure, I'll try to explain as best I can.

    Each subquery (they're not technically CTEs but subqueries) reads one of the separate tables to be joined, and assigns a sequential row#...

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

  • RE: Help Converting query -- Do I need a cursor?

    Maybe something along these lines?:

    SELECT

    COALESCE(ern.EmployeeID, tax.EmployeeID, ded.EmployeeID, ben.EmployeeID) AS EmployeeID,

    MAX(ern.PayCode) AS EarningPayCode,

    MAX(ern.Units) AS EarningUnits,

    MAX(ern.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".

  • RE: Parallel query execution from linked servers

    Not directly, at least not easily.

    But you could put each in a separate job and start the three jobs -- the sp_start_job command runs and returns immediately, without waiting for...

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

  • RE: How to re-org the grouping with case

    Create a Policy lookup table to assign the common policy id and the sort order:

    CREATE TABLE Reporting_PolicyGrouping (

    Policy_Name varchar(50) NOT NULL,

    Policy varchar(50)...

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

  • RE: How to re-org the grouping with case

    WHERE (INSERT_DETECT_TS between '20150602' and '20150603')

    You cannot safely use between. You need to use the >= and < (not <=, as in between) that I used earlier:

    WHERE (INSERT_DETECT_TS >=...

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

  • RE: Asynchronous Cursor Population Slow for Large Result Sets

    I don't think SQL is using async processing for that specific cursor, based on this information from Books Online:

    "

    SQL Server does not support generating keyset-driven or static Transact-SQL cursors asynchronously....

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

  • RE: Help with Totals per half hour timeframe

    drew.allen (7/6/2015)


    You were actually very close. The problem is here.

    order by ABS (DateAdd(Minute, 30 * (DateDiff(Minute, 0, closedate) / 30), 0)) ASC

    DATEADD() returns a date/time and ABS() takes a...

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

  • RE: Turning datediff minutes into dd:hh:mm

    select c.APPLICANT_ID as [Applicant ID], aetc.EVENT_TYPE as [Event Type],

    cast(aetr.CREATE_DATE as date) as [Registration Date],

    cast(aetc.CREATE_DATE as date) as [C Creation Date],

    right('0' + cast(minutes_diff / 1440 as varchar(2)), 2)...

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

  • RE: what's the best practice to count distinct?

    Edit: changed these comments:

    Most important is to change the WHERE to not use functions on the table column.

    You should also very strongly analyze clustering the table by INSERT_DETECT_TS (add Incident_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".

  • RE: How show only first friday of every month

    Here's a completely setting-independent way to calc only Fridays; it's actually a straight-forward task. Note: Since my software at work blocks CTEs (as some type of "injection"), I had...

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

  • RE: How to find if a database has been access/used since last month.

    There's no really good way to do that because it's so difficult. A db could be referenced by a linked server or by a 3-part name contained in dynamic...

    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 - 4,981 through 4,995 (of 7,613 total)