Forum Replies Created

Viewing 15 posts - 1,096 through 1,110 (of 7,619 total)

  • Reply To: SQL Query Help on Time based query

    Probably this?!:

    ;WITH Cte_Test_With_Row_Nums AS (
    SELECT *,
    ROW_NUMBER() OVER(PARTITION BY UserID, Schedule_Start_Date ORDER BY Start_Time) AS row_num
    ...

    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 alias or update tablename when from clause is specified

    Jeff Moden wrote:

    ScottPletcher wrote:

    Once you assign an alias to a table, that alias is the only valid way to reference that table.  That's not a matter of preference or opinion.  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: Update alias or update tablename when from clause is specified

    Jeff Moden wrote:

    You have to understand... I don't actually care what the question was.  This isn't stack overflow.  I was teaching about the proper forms and you don't need a 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".

  • Reply To: Update alias or update tablename when from clause is specified

    Jeff Moden wrote:

    ScottPletcher wrote:

    Jeff Moden wrote:

    There is no need for the FROM clause in the first example.

    I also prefer the second example because it's easy to change it to a SELECT 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: Update alias or update tablename when from clause is specified

    Once you assign an alias to a table, that alias is the only valid way to reference that table.  That's not a matter of preference or opinion.  It's a SQL...

    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 alias or update tablename when from clause is specified

    Jeff Moden wrote:

    There is no need for the FROM clause in the first example.

    I also prefer the second example because it's easy to change it to a SELECT to see what...

    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: Enclosure

    Within other quotes, you have to double up the single quotes around the date, like so:

    SET @Where = @Where + ' T0.U_DATE BETWEEN ''20210301'' and ''20210331'' '

    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: clustered index usage

    For doing single row lookups, a nonclustered index (NI) on a heap is no worse performance than a clustered index (CI).  However, as Grant noted, SQL does truly prefer CIs.

    If...

    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: Extract certain string before a particular string

    IF you want to extract the value after 'number="' in the string:

    SELECT *,
    SUBSTRING(string, NULLIF(CHARINDEX('number="', string), 0) + 8,
    ...

    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: Grouping by hour and minute from TimeStamped data

    No sample data, so unable to test.  You might have to include DATENAME(WEEKDAY, CA1.[Start Time]) in the GROUP BY, but I don't think that's required.  I can't remember for sure...

    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: permissions

    Michael L John wrote:

    ScottPletcher wrote:

    frederico_fonseca wrote:

    ScottPletcher wrote:

    Jeff Moden wrote:

    ScottPletcher wrote:

    "I review it".  How long does THAT take?

    And why does it need reviewed for "safety" if they don't have the permissions to change anything...

    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: permissions

    Ed Wagner wrote:

    frederico_fonseca wrote:

    ScottPletcher wrote:

    Jeff Moden wrote:

    ScottPletcher wrote:

    "I review it".  How long does THAT take?

    And why does it need reviewed for "safety" if they don't have the permissions to change anything on...

    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: permissions

    frederico_fonseca wrote:

    ScottPletcher wrote:

    Jeff Moden wrote:

    ScottPletcher wrote:

    "I review it".  How long does THAT take?

    And why does it need reviewed for "safety" if they don't have the permissions to change anything on the...

    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: permissions

    Jeff Moden wrote:

    ScottPletcher wrote:

    "I review it".  How long does THAT take?

    And why does it need reviewed for "safety" if they don't have the permissions to change anything on the instance??

    What on...

    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: permissions

    Jeff Moden wrote:

    ScottPletcher wrote:

    frederico_fonseca wrote:

    ScottPletcher wrote:

    Hold on.  I explicitly stated that auditors should not be able to change anything on the system.  Talking about giving auditors "sysadmin" is a straw man.

    Scripts that...

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