Forum Replies Created

Viewing 15 posts - 631 through 645 (of 7,613 total)

  • Reply To: table design for user "matching"

    Btw, neither "matched" nor "user_id" are SQL Server reserved keywords.

    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: table design for user "matching"

    A trigger makes the most sense to me, so that the assignments are immediate.  You would also need a DELETE trigger to remove interested / mutual for a deleted user_id...

    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: Need some expert help from the masters

    Btw, as noted by some others, I too, fortunately, have never seen any automated tool that can really properly analyze index usage and make really good suggestions for changes.  You...

    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: Need some expert help from the masters

    SQL already captures the vast bulk of the stats you need, thus you don't generally have to set up separate runs, etc. to capture activity.

    If you're willing to run 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: how to change hard coded dates to ytd please

    DECLARE @EndDate date
    DECLARE @StartDate date

    SET @StartDate = '20220101' --<<-- change @Start and @End values to get any date range you want
    --get end of current month
    SET @EndDate =...

    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: Removing a Column

    Btw, you should always specify nullability (NULL / NOT NULL) when ADDing a column, otherwise it's extremely difficult to determine what you'll get there.

    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: Selecting State from table based on a Begin and End Date

    To get the last datetime for a given set of datetimes, you'd typically use ROW_NUMBER(), like this:

    select ...
    From (
    select *, row_numnber() over(partition by...

    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: Need some expert help from the masters

    ScottPletcher wrote:

    Jeff Moden wrote:

    igaytwanb wrote:

    Hello everyone!

    I am in dire need of some assistance or direction. I am by no means a expert at any of this stuff. Unfortunately for me 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: Need some expert help from the masters

    Jeff Moden wrote:

    igaytwanb wrote:

    Hello everyone!

    I am in dire need of some assistance or direction. I am by no means a expert at any of this stuff. Unfortunately for me the company...

    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: Conversion of currency stored as varchar to decimal

    SELECT CONVERT (decimal(9, 2) , CAST('$15,000.50' AS money))

    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: query one table three for three different where variables

    No need to specify the last day / number of days in the month, that can easily be calculated:

    (CASE WHEN MONTH = @month AND DAY = @day...

    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: a good book on SQL

    I agree.  In fact, any book on T-SQL by Ben-Gan will be worth studying.

    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: How to get Key based on type and sub type

    aaron.reese wrote:

    You might find it easier to reason about with EXCEPT and INTERCECT.

    SELECT DISTINCT KEY FROM myTable WHERE type = 'COLL' and subtype = 'MOD'

    EXCEPT

    SELECT DISTINCT KEY...

    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: How to get Key based on type and sub type

    Yes.  If you only want a key that has both conditions, change the MAX:

    MAX(CASE WHEN type = 'QUAT' AND subtype = 'BALANCE' THEN 1 ELSE 0 END) = 1

    Note 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".

  • Reply To: How to get Key based on type and sub type

    SELECT key
    FROM dbo.your_table_name_here
    GROUP BY key
    HAVING MAX(CASE WHEN type = 'COLL' AND subtype = 'MOD' THEN 1 ELSE 0 END) = 1 AND
    MAX(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".

Viewing 15 posts - 631 through 645 (of 7,613 total)