Forum Replies Created

Viewing 15 posts - 1,141 through 1,155 (of 7,619 total)

  • Reply To: Truncate vs Delete for Bulk Removal of (some not all ) records

    Is the existing clustered composite key unique?  And explicitly declared to SQL as unique?

    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: Restore Database with RECOVER generates new values for identity columns

    Yes, absolutely.  The test server has no idea what identity values are being assigned in prod and vice versa.

    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: multiple queries

    ;WITH cte_dates AS (
    SELECT CAST(GETDATE() AS date) AS today,
    DATEPART(HOUR, GETDATE()) AS today_hour,
    ...

    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 use a single stored procedure with one to 10 parameters

    The code below generates SQL for from 1 to 20 @Tank entries, based on which ones were actually provided in the call to the proc, and then EXECs the code. ...

    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: Find the multiple records by max date

    SELECT
    [Shelf Location], date /*, ...*/
    FROM (
    SELECT *, DENSE_RANK() OVER(PARTITION BY [Shelf Location] ORDER BY date DESC) AS rank_num
    ...

    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: Splitting one wide column into serveral different ones

    I see no way to accurately parse that data will all the variations presented (and any number even worse than that that could happen).

    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: Alter default SQL generated in context menu top 1000

    If ID is (nearly) always an identity column, you can use ORDER BY $IDENTITY, that way you don't need to know the exact column 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: New Index Maintenance Methods Recommended by Microsoft

    Jeff Moden wrote:

    ScottPletcher wrote:

    Jeff Moden wrote:

    ScottPletcher wrote:

    Jeff Moden wrote:

    As a bit of a sidebar, wouldn't adding more files add to the problem you spoke of previously?

    I'm not sure which specific "problem" you're referring...

    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: Two identical queries have different execution plans (one cursor one not)

    It actually does explain it.  If SQL has to do a sort to get the rows in the correct order, then the cursor would be required to do a sort...

    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: Two identical queries have different execution plans (one cursor one not)

    Sorry to have bothered you then.  Good luck with this.  (I believe if you changed your cursor to LOCAL FAST_FORWARD (as in standard in SQL Server unless you explicitly need...

    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: Two identical queries have different execution plans (one cursor one not)

    You should change the index so that it has the proper sort order already, which will (should) avoid the sort in the query:

    CREATE NONCLUSTERED INDEX [IX_ImageProduct_MID] 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".

  • Reply To: New Index Maintenance Methods Recommended by Microsoft

    Jeff Moden wrote:

    ScottPletcher wrote:

    Jeff Moden wrote:

    As a bit of a sidebar, wouldn't adding more files add to the problem you spoke of previously?

    I'm not sure which specific "problem" you're referring to.

    The one...

    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: Query runs slow sometimes and sometimes runs superfast (2 minutes vs 2 seconds)

    Jeffrey Williams wrote:

    This is not going to allow index usage in the join: AND KeyValue = (co.co_num + '-' + CAST(coitem.co_line AS VARCHAR(10)) + '-0' )

    SQL can use an index 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".

  • Reply To: SQL query help

    jcelko212 32090 wrote:

    fake_pointer ???? NOT NULL);

    The reason you are using big integers is because they look like pointers. But we don’t use pointers in RDBMS. You’re using SQL to write assembly...

    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: New Index Maintenance Methods Recommended by Microsoft

    Jeff Moden wrote:

    As a bit of a sidebar, wouldn't adding more files add to the problem you spoke of previously?

    I'm not sure which specific "problem" you're referring to.

    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,141 through 1,155 (of 7,619 total)