Forum Replies Created

Viewing 15 posts - 4,126 through 4,140 (of 7,613 total)

  • RE: how can I use a sproc @param as column alias?

    Sample dynamic SQL:

    DECLARE @MySprocParam VARCHAR(50) = 'TestAlias'

    EXEC('SELECT ''ASDF'' AS [' + @MySprocParam + ']')

    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: Backup database only if changes happen

    Eric M Russell (9/28/2016)


    ScottPletcher (9/28/2016)


    You'd still need to keep at least the history from the previous check, because an index/table could be dropped, which would remove it from the system...

    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: Backup database only if changes happen

    You'd still need to keep at least the history from the previous check, because an index/table could be dropped, which would remove it from the system views.

    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: Select top ..., with extra conditions

    Option (1) should be fine as long as the trigger is efficiently written and there is an index to support the trigger's query. For example, if the table 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: Help with sorting data from two tables

    USE HandsOnOne;

    SELECT c.CustomerName, a.City, a.State

    FROM Customer c

    INNER JOIN Address a

    ON a.AddressID = c.CustomerAddressID

    ORDER BY a.ZipCode ASC, c.CustomerName ASC;

    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: Test Function for Performance Statistics

    You could populate a table with the test values you want to us, then process from it in a loop or by using GO <#_of_test_runs>, which I used below 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: Backup database only if changes happen

    The irony is it might be more overhead to check for the updates than to just do the log transfers.

    In theory you might (should?) be able to use sys.dm_db_index_operational_stats 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".

  • RE: Searching for a value across all columns of a single table

    I suggest using a CASE technique to add the desired matches because that method gives you great flexibility on specifically what values to match. The code is somewhat longer,...

    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 Upgrade T-SQL Skills

    Lynn Pettis (9/27/2016)


    ScottPletcher (9/27/2016)


    Talib123 (9/27/2016)

    I'm a production DBA

    ... how do I get my T-sql skills to a developer\Report writer level.

    So you want to go from DBA-level SQL to developer-level SQL:

    Destroy...

    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: Dynamically creating a @table Table from a current table

    You don't need a global temp table, a regular temp table will do.

    Create the table in main stored proc, then ALTER it using dynamic SQL. Since the temp table...

    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 Upgrade T-SQL Skills

    Talib123 (9/27/2016)

    I'm a production DBA

    ... how do I get my T-sql skills to a developer\Report writer level.

    So you want to go from DBA-level SQL to developer-level SQL:

    Destroy half your brain...

    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: Dynamically creating a @table Table from a current table

    I can't think of a way right now for that to work using a table variable.

    Can you use a temp table instead?

    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: Looking to update old code

    Eric M Russell (9/26/2016)


    ScottPletcher (9/26/2016)


    Eric M Russell (9/26/2016)


    ScottPletcher (9/23/2016)


    Eric M Russell (9/23/2016)

    Regardless of SQL Server version, performance optimization should start by looking at execution plans.

    Not necessarily. If the best...

    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: Keep accurate inventory value

    First, cluster the tables for best (overall) performance. In particular, don't assume that every table should be clustered by identity. That's most often simply not the best way...

    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: Looking to update old code

    Eric M Russell (9/26/2016)


    ScottPletcher (9/23/2016)


    Eric M Russell (9/23/2016)

    Regardless of SQL Server version, performance optimization should start by looking at execution plans.

    Not necessarily. If the best clustered indexes are not...

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