Forum Replies Created

Viewing 15 posts - 5,176 through 5,190 (of 7,619 total)

  • RE: Performance optimization in stored procedure to perform sorting and filtering

    This should definitely be faster. I've tested it for ASC sort but not for DESC -- I believe I've coded it to correctly handle DESC sort, I just haven't...

    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: Insert DATE --Confused with convert

    Orlando Colamatteo (4/22/2015)


    I'll second the point: definitely store your dates and times in a column of type DATETIME. If you make that a non-negotiable starting point the rest of this...

    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: Job To Delete All Records Then Copy All From Another Table

    As an aside, if possible, TRUNCATE the table rather than use DELETE to reduce logging.

    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: Use cursor to run dynamic SQL to find special characters used in database

    Mark Finnie (4/21/2015)


    Thank you Scott. I had to replace TableName with TblName becuase some audit tables had columns with that name, resulting in ambiguous column name errors. The query then...

    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: Update statement performance

    Code below could perform better, esp. if table2 and table3 don't have an index that directly supports the lookup/comparison being done.

    Edit: And performance could be worse with this 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".

  • RE: Creating Rows Between Dates In A Single SQL Statement

    Another perfect situation for a tally table. You can create an in-line table using CROSS JOINs or create a physical tally table and use that. Unfortunately I can't...

    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: Use cursor to run dynamic SQL to find special characters used in database

    I used CASE rather than ORs ;-).

    SET NOCOUNT ON

    --Temp table DROP/CREATE, in alpha order--------------------------------------------------------------------------------

    IF OBJECT_ID('tempdb.dbo.#CheckTables') IS NOT NULL DROP TABLE #CheckTables

    IF OBJECT_ID('tempdb.dbo.#Results') IS NOT NULL DROP TABLE #Results

    CREATE TABLE #CheckTables...

    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: Use cursor to run dynamic SQL to find special characters used in database

    If the code ran in just 8 minutes, and you like it and results, it's logical for you to leave it as is.

    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: Check existence of a database

    I agree. You'd expect the specifically-chosen (?) "featured script" to be something at least moderately good/useful, but most often they are not.

    As for this code, I would suggest simply:

    SELECT...

    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: Get just the .mdf and .ldf names not the path.

    Alan.B (4/17/2015)


    Nope, not that I am aware of. Not without using a sp_cmdshell or other non-tsql scripting tool

    What's wrong with this?

    SELECT

    DbName = db.name,

    FileType =...

    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: Alter Function - took long time ...

    There could also be some type of locking, and thus blocking, on the underlying system tables. I've seen this happen when, for example, people do a "SELECT ... INTO...

    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: Baffled by Query

    Since you're trying to do a keyed lookup on the CL table, the conversion should be other way around to allow SQL to do a seek on all three 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".

  • RE: Converting job duration from Job History and use it on email notifications

    I see a couple of other issues, besides formatting, with your code.

    1) Step 0 is a summary for the entire job, including duration. So if you add step 0...

    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: PK Non-CLUSTERED to CLUSTERED

    there is a pre-set default fillfactor, but I've seen it set as low as 70%, it's not automatically 100%.

    RonKyle (4/20/2015) What does this mean? The default is 0 (100%)....

    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: PK Non-CLUSTERED to CLUSTERED

    RonKyle (4/20/2015)

    ...Be careful of fillfactor, else it is possible that your table ends up taking up more space, unless that is what is expected.

    If your choice of a clustered index...

    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 - 5,176 through 5,190 (of 7,619 total)