Forum Replies Created

Viewing 15 posts - 1,891 through 1,905 (of 7,619 total)

  • Reply To: Add column to existent table with default costraint value based on condition

    ktflash wrote:

    would be nice to have something like this i guess, sucks it doesnt work

    create table #table
    (old_column int)

    insert into #table
    values(1),(2)

    alter table #table
    add new_column int default (case when...

    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: Restoring a backup with a changing name

    You can change the default file locations when installing SQL Server.  You can also move the system databases later if you want 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".

  • Reply To: Dynamic Data Masking and Adhoc queries.

    Use ENCRYPTBYASYMKEY and DECRYPTBYASYMKEY.

    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: Add column to existent table with default costraint value based on condition

    No, not that way.

    But, for this situation, you could make it a computed / virtual column.

    ALTER TABLE [MyTable1]

    ADD NewRange AS CAST(CASE WHEN Status <> 'AAA' /* OR Status IS NULL?...

    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: Update Column Based on Criteria from Other Columns -- improved post included DDL

    Would you modify the sample data to include the "Theoretical Cycle Number", i.e. the desired cycle number you want added to each row.

    I still don't fully understand all the criteria...

    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: Restoring a backup with a changing name

    In your specific version of SQL, there may be different columns returned by the FILELISTONLY command.  Run a FILELISTONLY command in the main window and compare the columns that come...

    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: Question related to architecture

    If there are existing overlapping object names, I'd resolve them -- i.e. rename one of the objects -- as part of the rework.  So that, even if stored in separate...

    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: Preventing duplicate execution plans

    1 Be sure to specify the schema name on the table, assuming of course that it doesn't change from user to user.

    FROM dbo.MYTABLE

    2. Make the variable the exact same type...

    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: Restoring a backup with a changing name

    Here's the revised code.  It should work exactly as written now.

    DECLARE @sql nvarchar(max)

    IF OBJECT_ID('tempdb.dbo.#restore_filelistonly') IS NOT NULL
    DROP TABLE #restore_filelistonly;
    CREATE TABLE #restore_filelistonly (
    ...

    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: Restoring a backup with a changing name

    Something along the lines below, adjust it as needed to match your environment.  You didn't say anything about changing path names for the files, so I just used the paths...

    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: Replacing String Between Two HTML Tags

    Paul McCaffrey wrote:

    ScottPletcher wrote:

    ...hope you can work it out.

    You really need to provide truly representative sample data if you want a full solution.

    With the sample data thing, with this one it's...

    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: CheckDB TempDB usage

    It seems like you might have a (very) old transaction running.

    See what this tells you:

    USE tempdb;

    DBCC OPENTRAN;

     

    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: Replacing String Between Two HTML Tags

    ...hope you can work it out.

    You really need to provide truly representative sample data if you want a full solution.

    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: Convert International Character-String Date Formats

    I once was getting horribly flawed data from FedEx (missing closing quotes, missing delimiters, etc.; genuinely not expected, given their rep).  They would NEVER fix the data.  We had 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".

  • Reply To: Replacing String Between Two HTML Tags

    I think this is right.  Naturally you'll need to confirm for yourself, as I don't have any additional test data.

    IF OBJECT_ID('tempdb.dbo.#data') IS NOT NULL
    ...

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