Forum Replies Created

Viewing 15 posts - 736 through 750 (of 7,613 total)

  • Reply To: Return data from a calendar table with associated active events

    Btw, you don't seem to realize that you are not including the last day of the month in the Calendar table.

    CREATE OR ALTER VIEW Test
    AS
    SELECT * 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: Left JOIN Works Appears to Only Work with Certain Table

    That join will work fine too.

    Try an ORDER BY C1.RowNum so that you can see the matches between rows, if any, in order.

    SELECT C1.Id
    ...
    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: While Loop Data Issue

    Best practice is to use a tally table in preference to a loop, so I added that to the code.  No test data provided so I couldn't test the code.

    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: Please help to get, Alphabet with underscore i.e special charecter

    Steve Collins wrote:

    Afaik this actually produces the desired output.  Should work with SQL 2014.  It uses the ordinal splitter DelimitedSplit8K_Lead.  The query: splits the input string on '_' underscore, finds 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: space report

    If you've got the time to wait for it to run 🙂

    It really makes no sense to send every db file thru 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: space report

    Here's a stand-alone version of the proc I created for work.  Naturally adjust is as needed to match your requirements.  The proc goes into the master db (and is marked...

    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: Please help to get, Alphabet with underscore i.e special charecter

    I thought later of one possible correction to removing the file extension, just in case two or more periods (.) appear in the value.

    SET ANSI_NULLS ON
    SET QUOTED_IDENTIFIER...

    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: PATINDEX question

    (tbd)

    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: Please help to get, Alphabet with underscore i.e special charecter

    SET ANSI_NULLS ON
    SET QUOTED_IDENTIFIER ON
    GO
    CREATE FUNCTION [dbo].[fn_GetAlphabetsAndUnderscoresOnly]
    (
    @string VARCHAR(8000)
    )
    RETURNS VARCHAR(8000)
    AS
    BEGIN
    DECLARE @invalidCharLocation SMALLINT
    SET @string = LEFT(@string, CHARINDEX('.', @string + '.') - 1)
    SET @invalidCharLocation = PATINDEX('%[^A-Za-z_]%',...

    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: First responders kit - BlitzIndex question

    Wingenious wrote:

    ScottPletcher wrote:

    Wingenious wrote:

    The missing index suggestions are not connected to specific queries in versions prior to SQL Server 2019. SQL Server 2019 added the sys.dm_db_missing_index_group_stats_query DMV. This DMV tells...

    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: First responders kit - BlitzIndex question

    Wingenious wrote:

    The missing index suggestions are not connected to specific queries in versions prior to SQL Server 2019. SQL Server 2019 added the sys.dm_db_missing_index_group_stats_query DMV. This DMV tells you which...

    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: Populate Column Based on Distinct Values

    Kin16 wrote:

    Sorry for the confusion. Yes, as the data stands right now the entire column should be populated with an *. If the department column included 0001 and 0002, then...

    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: Populate Column Based on Distinct Values

    I'm not really sure what you're trying to do, but it sounds like something like this:

    UPDATE tn
    SET tn.[Export Deparment] = CASE WHEN Distinct_Department_Count = 1 THEN '*'...

    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: Incorrect syntax near the keyword end

    Also, since the table you are INSERTing to already exists, you need to INSERT to it, not SELECT ... INTO it:

    Truncate TABLE Planning

    Insert Into Planning
    Select *

    from (select...

    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: Quick SQL challenges for mid-experienced+ DBAs (and advanced T-SQLers)

    (2) Here's my answer:

    CREATE TABLE dbo.emp_training ( id int IDENTITY(1, 1) NOT NULL, emp_id int NOT NULL, training_id int NOT NULL, status char(1) NULL CHECK(status IN ('F',...

    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 - 736 through 750 (of 7,613 total)