Forum Replies Created

Viewing 15 posts - 406 through 420 (of 7,619 total)

  • Reply To: Run Stored Procedure on the first Monday if each month of Tues if Mon Holiday

    Jonathan AC Roberts wrote:

    ScottPletcher wrote:

    @jonathan-2:

    This method of determining Tuesday:

    DATEPART(weekday, @CurrentDate) = 3

    requires a specific DATEFIRST setting to work correctly.  Many business have locations around the world, so it's safer to use 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".

  • Reply To: Run Stored Procedure on the first Monday if each month of Tues if Mon Holiday

    Fair enough.

    In that case, let's create a view that has the merged tables for anyone to use.  That is much cleaner.

    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: Run Stored Procedure on the first Monday if each month of Tues if Mon Holiday

    Yikes, if a developer can't join/merge two tables with distinct date values to a combined table, they need additional training, and pronto.

    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: Run Stored Procedure on the first Monday if each month of Tues if Mon Holiday

    Personally I prefer a nonworkdays-only table (I don't call it a "holiday" table because sometimes it's a nonwork day but not a holiday (such as for a power outage, etc.)).

    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: Run Stored Procedure on the first Monday if each month of Tues if Mon Holiday

    <removed, dup comment>

    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: Run Stored Procedure on the first Monday if each month of Tues if Mon Holiday

    @jonathan-2:

    This method of determining Tuesday:

    DATEPART(weekday, @CurrentDate) = 3

    requires a specific DATEFIRST setting to work correctly.  Many business have locations around the world, so it's safer to use a method 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: Run Stored Procedure on the first Monday if each month of Tues if Mon Holiday

    @dennis Jensen:

    I never presume to know the requirements of the task better than the person requesting the code.

    "If the first Monday of the month is a holiday, than I need...

    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: Run Stored Procedure on the first Monday if each month of Tues if Mon Holiday

    I'd strongly urge you not to mess with the DATEFIRST setting.  You don't need to, and it could throw off other code which might need a different setting (if 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: Run Stored Procedure on the first Monday if each month of Tues if Mon Holiday

    I don't believe you can do this directly.  However, you could have the first step of the job determine if it is a holiday, and if so, to schedule 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".

  • Reply To: Condensed resultset distinct

    Your ordering is not guaranteed to be in the OUT ITEM order, since you don't sort by it.

    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: Condensed resultset distinct

    If you have a lot of rows, you'd likely get better performance putting the results (from the cte) into an indexed temp table, but for now, just see if this...

    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: tsql help

    An alternative that allows a previous open paren(s) in the input data:

    DROP TABLE IF EXISTS #test2;
    CREATE TABLE #test2 ( tran_log_writes nvarchar(4000) NULL );
    INSERT #test2 ( tran_log_writes )...

    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: I have string data in a column and i need to strip out parts of it.

    Personally for something this involved / complex, I'd use a custom function that parsed with pre-determination.  That is, the code doesn't look only for specific names (tags) in the data,...

    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: Syntax issue while trying to create index on filegroup

    You specify either a partition or a filegroup, not both (if partition, the partitioning will determine the filegroup(s) used).

    create index IX_Service_Start_Date ON ivc_cds.CDS_Claim_Header (Service_Start_Date )

    WITH (FILLFACTOR = 98, SORT_IN_TEMPDB =...

    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: below script with STUFF function executes 2014 but not in 2019 version

    Try this:

    SELECT DISTINCT Lotr.LabOrderUnique,
    STUFF( (SELECT DISTINCT CAST('^' AS varchar(max)) + CAST(lotr1.TestName AS varchar(max))
    FROM dbo.Ncs_conv_IntergyMM_Labordertestresult AS...

    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 - 406 through 420 (of 7,619 total)