Forum Replies Created

Viewing 15 posts - 5,671 through 5,685 (of 7,613 total)

  • RE: How to name a column the same name of a tablename

    Sorry [that did seem rather obscure for a starting class on SQL].

    In the SELECT list, after the original column name or expression, you can add "AS new_column_name", and the query...

    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: Redo: Insert/Update Triggers Causing Problems when an Insert is ran via Script

    I guess rename one of them. But better to avoid using temp tables in a trigger unless absolutely necessary.

    The triggers probably need re-written. Post them here and we...

    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 name a column the same name of a tablename

    You can use system procedure:

    sp_rename

    to rename a column. The general format is like this:

    EXEC sp_rename 'table_name.existing_column_name', 'new_column_name', 'COLUMN'

    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 Sql Server Ageng Job Id from within a running job

    patrickmcginnis59 10839 (10/23/2014)


    ScottPletcher (10/23/2014)


    arnipetursson (10/23/2014)


    ScottPletcher (10/22/2014)


    You should be able to use the session_id to do the lookup. But since session_ids are reused, and sysjobactivity keeps history, if your proc...

    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: restore a database with more than two data files and more than one log file situation (automated)

    I suggest gen'ing the MOVE clauses directly from @tables, ignoring the count. Just concatenate all the results into a RESTORE statement, and run that statement dynamically. For example:

    ...existing...

    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 Sql Server Ageng Job Id from within a running job

    arnipetursson (10/23/2014)


    ScottPletcher (10/22/2014)


    You should be able to use the session_id to do the lookup. But since session_ids are reused, and sysjobactivity keeps history, if your proc is not currently...

    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 Sql Server Ageng Job Id from within a running job

    And those same guys obviously did contract work for healthcare.gov! 😀

    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: Finding procedures that use declared table variables

    For temp tables, you must also consider:

    INTO #new_temp_table

    rather than just CREATE.

    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: local managed tablespace & dictionary managed tablespace

    Those sound like Oracle qs, but this is a SQL Server forum.

    You would likely get much better responses to your q by posting it in an appropriate Oracle forum.

    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: Rank duplicates, but only rows involved in duplicates

    jeff.born (10/22/2014)


    The solution with the min and max would work if there were only duplicates, but Businesses have been known to be duplicated 100s of times due to previous incorrectly...

    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: Rank duplicates, but only rows involved in duplicates

    SELECT

    [BusinessName], [Address], [Phone]

    ,MIN(Business_pk) AS Business_pk_min,

    ,MAX(Business_pk) AS Business_pk_max

    FROM [dbo].[TestBusiness] bus

    INTO [dbo].[DuplicateBusinesses]

    GROUP BY

    [BusinessName], [Address], [Phone]

    HAVING COUNT(*) > 1

    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 Sql Server Ageng Job Id from within a running job

    You should be able to use the session_id to do the lookup. But since session_ids are reused, and sysjobactivity keeps history, if your proc is not currently running from...

    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: Replacing a CASE statement in an update with table-driven logic

    Frank The Tank (10/21/2014)


    Thanks for all of the responses. Lots of interesting ideas. The computed column approach is probably the most elegant, but it was met with a...

    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: Replacing a CASE statement in an update with table-driven logic

    Phil Parkin (10/21/2014)


    ScottPletcher (10/20/2014)


    If the controlling column(s) are all from the same table, I suggest a computed column. That leaves the defining logic in only a single place, and...

    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: Can I change colum width of varchar in production

    Increasing the size of a [n]varchar column isn't directly a problem.

    But, if you think people will go back and increase the length of those columns in a significant...

    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,671 through 5,685 (of 7,613 total)