Forum Replies Created

Viewing 15 posts - 16 through 30 (of 58 total)

  • Reply To: Ensuring a Single Row Table

    There are other ways for enforcing cardinality of 1. here is one of them:

    CREATE TABLE SingleRowTable

    (

    DataColumn varchar or whatever

    ,  CheckColumn int  UNIQUE CHECK (CheckColumn=1)

    )

    CheckColum can store 1...

    Zidar's Theorem: The best code is no code at all...

  • Reply To: How to Improve Database Design to Speed Up SQL Queries

    I agree with Jeff 100%.  Performance is paramount, assuming the foundation is sound. Bot fast and safe at the same time is an ultimate goal, but at the same time...

    Zidar's Theorem: The best code is no code at all...

  • Reply To: How to Improve Database Design to Speed Up SQL Queries

    I must commend the author for this one

    "In some situations, there is no column guaranteed to be unique for each entry, and developers might be tempted to rely on surrogate...

    Zidar's Theorem: The best code is no code at all...

  • Reply To: Get the Most Current Row From a Detail Table

    How about avoiding UPDATE altogether, this query seemed fast enough to me:

     

    WITH Last_Columns AS
    (
    SELECT object_id, MAX(column_id) AS LastCol
    FROM #columns
    GROUP BY object_id
    )
    SELECT T.Object_ID, C.LastCol
    FROM #tbl AS T
    JOIN Last_Columns...

    Zidar's Theorem: The best code is no code at all...

  • Reply To: Left Outer Join Check

    Grant is very right. When you want to apply LEFT OUTER JOIN to a subset of outer table, do not place condition in WHERE clause. Place it in ON clause.

    Itzik...

    Zidar's Theorem: The best code is no code at all...

  • Reply To: Developer Optimism

    "

    The primary problem is management. They tolerate mediocre performance and they set the standards.

    As long as we rely on Full-Stack-Developers, SQL will go the way of the dodo. Sure, like...

    Zidar's Theorem: The best code is no code at all...

  • Reply To: Substitute 0 and 1 values in 1 column

    <quote>UPDATE dbo.table_name SET column = ABS(column - 1)<quote>

    Nice touch! I have not seen this trick in a long time. Congrats and thank you 🙂

    Zidar's Theorem: The best code is no code at all...

  • Reply To: Query Tuning, Why Bother?

    ZZartin: "This is only partially true, database constraints can prevent bad data from getting into the data base.  They do not however free developers from having to both know/understand those...

    Zidar's Theorem: The best code is no code at all...

  • Reply To: Query Tuning, Why Bother?

    This is for  @skeleton567, post with a Bible quote 🙂

     

    I am not blaming neither DBAs nor developers. It is simply true. Good database design actually frees developers from enforcing data...

    • This reply was modified 3 years, 9 months ago by Zidar. Reason: Post appeared on unexpected position, at the end instead the post I was replying to

    Zidar's Theorem: The best code is no code at all...

  • Reply To: Query Tuning, Why Bother?

    One more small thing: if we are dealing with poor database design, sometimes neither tuning nor hardware helps.

    Zidar's Theorem: The best code is no code at all...

  • Reply To: Retrieve records added across database (all user table) after a specific date

     

    Can the poster show us how was the problem resolved. "If a table does not have DateCreated, how would 'the system' know which of its rows to select?"

    Zidar's Theorem: The best code is no code at all...

  • Reply To: What Do We Want to See in SQL Server?

    - Add wizard for PIVOT, like one in MS Access

    - Expand list of Boolean operators, add implication =>  and equivalence <=>. It is cumbersome and confusing writing NOT P OR...

    Zidar's Theorem: The best code is no code at all...

  • Reply To: Create a report to count the # of days a physician has a case assigned

    Thi is what you gave us, approximately:

    DROP TABLE IF EXISTS #Doctors
    GO
    CREATE TABLE #Doctors
    (
    WorkDayDate date
    , Pathologist nvarchar(50)
    , [Today Pathologist had 6 cases] int
    , [Today Pathologist had 7 cases]...

    Zidar's Theorem: The best code is no code at all...

  • Reply To: Finding the row before the negative value

    Can you clarify the question? What does he "line before negative line" means? Is it negative Amount or negative Balance? In the example, you are actually displaying all "positive" lines...

    Zidar's Theorem: The best code is no code at all...

  • Reply To: Create a report to count the # of days a physician has a case assigned

    Please read the answer from pietlinden. Yo must provide CREATE TABLE statements and sample data, which allows to see the goal.

    No table structure, no data => no help available

    Zidar's Theorem: The best code is no code at all...

Viewing 15 posts - 16 through 30 (of 58 total)