Forum Replies Created

Viewing 15 posts - 511 through 525 (of 7,613 total)

  • Reply To: Additional records needed with Using MAX function on Most Recent Record

    ;WITH cte_last_visits AS (
    SELECT client_id,
    MAX(visit_date) AS last_visit,
    ...

    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 stats vs rebuilding indexes

    Grant Fritchey wrote:

    (less than 8 pages goes on mixed extents

    For SQL 2017 (or SQL 2016, for that matter), only if for some odd reason you've set MIXED_PAGE_ALLOCATION ON and/or allowed...

    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: Help with database design

    Jonathan AC Roberts wrote:

    ScottPletcher wrote:

    Jonathan AC Roberts wrote:

    ScottPletcher wrote:

    Jonathan AC Roberts wrote:

    I believe it's acceptable to use either singular or plural names for database table names,

    Acceptable, perhaps.  But can you name any major RDBMS that uses...

    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: Help with database design

    Jonathan AC Roberts wrote:

    ScottPletcher wrote:

    Jonathan AC Roberts wrote:

    I believe it's acceptable to use either singular or plural names for database table names,

    Acceptable, perhaps.  But can you name any major RDBMS that uses singular table...

    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: Code to sum hours and minutes (varchar), 800,000 rows.

    SwePeso wrote:

    DECLARE @sum INT;

    SELECT @sum = 60 * SUM(CAST(PARSENAME(REPLACE(x, ':', '.'), 2) AS INT)) + SUM(CAST(PARSENAME(REPLACE(x, ':', '.'), 1) AS INT))
    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: Help with database design

    Jonathan AC Roberts wrote:

    I believe it's acceptable to use either singular or plural names for database table names,

    Acceptable, perhaps.  But can you name any major RDBMS that uses singular table names in...

    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: Help with database design

    Tables are typically plural.

    I don't see why "user" should be in any of these names.

    So maybe:

    orgs ( orgId int, orgName varchar(100) )

    orgTypes ( orgTypeId smallint, orgType varchar(50) )

    orgSiteTypes ( orgSiteTypeId...

    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: Code to sum hours and minutes (varchar), 800,000 rows.

    DROP TABLE IF EXISTS #data;
    CREATE TABLE #data ( trip_duration varchar(30) NOT NULL );
    INSERT INTO #data VALUES
    ('23:01'), ('00:01'), ('05:15'), ('00:45'), ('00:11');

    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: How to pull Year from varchar field

     SELECT field, SUBSTRING(field, PATINDEX('%[2][0-9][0-9][0-9]%', field), 4) AS year
    FROM #t

    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: extended property

    None that I'm aware of.  It's actually an excellent place to store that type of info.

    Just be sure you don't drop the table, or you'll lose all the ext props!

    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: Get value after certain characters

    ;WITH test_data AS (
    SELECT 'A~B~C.ab' AS data
    UNION ALL
    SELECT 'D~E~FG.hij'
    )
    SELECT data, data_result
    FROM test_data
    CROSS APPLY (
    ...

    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: Azure SQL

    You would also want to check what the FK DELETE options are on each table.  For the ones that are CASCADE, that could cause updates in other tables as well...

    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: TempDB and FileSystem Space

    The way I figured it:

    Currently you have 10 files * 100GB reserved = 1000GB.

    If you drop each file to 85GB, you'll have 850GB reserved, i.e., 150GB less.  On a drive...

    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: TempDB and FileSystem Space

    Shrink files 3 thru 8 to, say, 85GB.  Then, wait a while.  Once the tempdb file sizes get more balanced out, shrink files 1 and 2 back to 85GB.  Ultimately...

    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: Change logfile extension and reduce its size

    As for renaming the file, do not use detach; that's an obsolete method.  Instead, issue an ALTER command to change the file name, take the database offline, rename the physical...

    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 - 511 through 525 (of 7,613 total)