Forum Replies Created

Viewing 15 posts - 5,806 through 5,820 (of 7,619 total)

  • RE: create column alias with concatenation.

    Another option is to rename the column(s) then use "SELECT *" for output:

    --CREATE TABLER #temp ...

    --INSERT INTO #temp ... ...

    DECLARE @sql varchar(8000)

    SET @sql = 'EXEC tempdb.sys.sp_rename ''#temp.sale'', ''Sales' + CAST(YEAR(GETDATE())...

    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: Evaluating a database

    I first look at SQL's usage stats (incl. row counts), operational stats and missing index info. Be aware they get reset when SQL stops and restarts, so you get...

    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: Table Record Access Counter

    You could start with a url summary table and add a details table later if you need to.

    I'd still strongly urge you to use an int to represent the url,...

    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: data type conversion and performance

    Create an index::

    keyed on : id

    INCLUDE : serialnumber

    Use quotes in the WHERE:

    WHERE id IN ('1', '2', '3')

    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: CHECKDB fails on MSDB and Master system databases

    You can really get around that error directly, as SQL has control of master.

    Back up the master db and restore it to a different name.

    RESTORE DATABASE master_dbcc_checkdb

    FROM DISK = 'x:\full\path\to\master.BAK'

    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: Removing database owner

    You can have odd errors occur in that situation.

    You're better off having a fixed, permanent owner for dbs and granting permissions as needed to other users, up to and including...

    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: Replace CASE WHEN expression by boolean logic?

    The second style would at least have a chance of being fully optimized, particularly if you force a recompile of the query. Stick with it.

    I'd avoid the first style...

    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 disable and enable the store procedure?

    The problem with a table is that one option must apply to everyone. Parameter or other methods allow customized runs, so that your own special cases can still run...

    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 disable and enable the store procedure?

    Eirikur Eiriksson (9/15/2014)


    ScottPletcher (9/15/2014)


    All of those seem far too disruptive to me.

    Two quick possibilities:

    1) Add an optional parameter to the proc which requires a certain value or the proc just...

    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: SQL Query Taking Too Long

    That GROUP BY is gonna kill your performance. See if the code below is close to what you need.

    I've added clustered indexes on the temp tables prior to loading...

    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: Missing Indexes Table

    You can't consider missing index info in isolation. At the very least, you also need to look at index usage stats. Both of those are the minimum needed...

    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: which insert is faster? with identity_insert on or identity_insert off

    The big delay is likely in allocating and formatting log space, not in the identity number assignment, which is trivial.

    Thus, before you run the big INSERT, pre-allocate sufficient log space...

    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 disable and enable the store procedure?

    All of those seem far too disruptive to me.

    Two quick possibilities:

    1) Add an optional parameter to the proc which requires a certain value or the proc just exits (or does...

    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: Using COALESCE and also trying to multiply and divide

    Luis Cazares (9/11/2014)


    Your little example is really nice, real life isn't like that.

    Please find the errors in the following code:

    INSERT INTO dbo.FactInternetSalesCopy

    (ProductKey, OrderDateKey, DueDateKey, ShipDateKey, CustomerKey,...

    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: where id <> 3 skips NULL value

    thomashohner (9/9/2014)


    I'm a noob but Predicates only evaluate to TRUE. Also NULL is not a value. Query 3 is correct as far as my very limited knowledge goes.

    So it skips...

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