Delete syntax not working

  • Jeff Moden - Saturday, November 11, 2017 7:59 PM

    jcelko212 32090 - Saturday, November 11, 2017 1:29 PM

    Jeff Moden - Sunday, November 5, 2017 7:25 PM

    jcelko212 32090 - Friday, November 3, 2017 4:57 PM

    >> The proprietary version of code works just fine especially since it's being used in a Microsoft product. And, no... it doesn't mean that it can behave any way it wants to. <<

    Really, you only program in Microsoft products today? No major corporation uses Oracle, DB2, Postgres or any other form of SQL? At an early point in my career. I decided I'd be the guy that taught very generic, very portable SQL and could get you past any of the FIPS requirements, if you were a federal contractor; I grew up during the Cold War. It stood me pretty well for about four decades now.

    Actually, proprietary code can pretty much behave anyway which it wants to. I had an article on the outer join syntax various companies had before the Standards. The extended equality had an Oracle version, and Microsoft version, and then there was the Informix version which went into the from clause rather than the where clause, they all behave slightly differently. Then of course within Microsoft. We had the definition of the BIT data type. Originally, it was what a computer science major with think of is a bit, namely having only the values {0, 1} as bit flags. Then suddenly it switched over to a numeric data type. But all numeric datatypes in SQL have to be nullable so now those columns became{0,1,NULL} I made a bundle on this one!

    Heh... Lots of major corporations use Oracle, DB2, Postgress, etc... I've worked for a couple of them, didn't like it (especially hated all 3 years working with Oracle even though I was good at it) and, unlike you, decided to get good at something instead of going generic.

    I am going to have to learn MondoDB and PostgreSQL where I work.  I will still be active with SQL Server there are well as SQL Server is used for corporate systems.  The MongoDB and PostgreSQL are for the products we develop.  Guess what, I still won't be writing generic SQL.  I will write SQL to the database engine where it will be run.  Guess that means where needed there will be two parallel code bases.

  • Lynn Pettis - Sunday, November 12, 2017 11:13 AM

    I am going to have to learn MondoDB and PostgreSQL where I work.  I will still be active with SQL Server there are well as SQL Server is used for corporate systems.  The MongoDB and PostgreSQL are for the products we develop.  Guess what, I still won't be writing generic SQL.  I will write SQL to the database engine where it will be run.  Guess that means where needed there will be two parallel code bases.

    That's actually one of the smartest plans I've heard someone talk about in a couple of years.

    We did the same thing for an Oracle conversion to SQL Server and made some improvements to the Oracle code base in the process.  Both turned out nasty fast and the conversions just weren't that difficult.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • Jeff Moden - Sunday, November 12, 2017 11:31 AM

    Lynn Pettis - Sunday, November 12, 2017 11:13 AM

    I am going to have to learn MondoDB and PostgreSQL where I work.  I will still be active with SQL Server there are well as SQL Server is used for corporate systems.  The MongoDB and PostgreSQL are for the products we develop.  Guess what, I still won't be writing generic SQL.  I will write SQL to the database engine where it will be run.  Guess that means where needed there will be two parallel code bases.

    That's actually one of the smartest plans I've heard someone talk about in a couple of years.

    We did the same thing for an Oracle conversion to SQL Server and made some improvements to the Oracle code base in the process.  Both turned out nasty fast and the conversions just weren't that difficult.

    It's the only thing to do because it's the best approach to the problem.  Different code is required to get the best performance from the engine where it's being executed.  So what if generic code can run on SQL Server, Oracle and whatever other database system someone pulls out?  If the generic code gets poor performance, then it sucks equally as bad across multiple database platforms.  If you can make it fly on the different systems, then there's no reason to use the generic garbage.

  • Hmm... looks like the OP has been scared away by all this talk of ISO standards, generic code, etc. 🙂
    The forum does have 'SQL Server' in the title after all. So offering an SQL Server only solution is not unreasonable (is it?).

  • nigel. - Monday, November 13, 2017 1:34 AM

    Hmm... looks like the OP has been scared away by all this talk of ISO standards, generic code, etc. 🙂
    The forum does have 'SQL Server' in the title after all. So offering an SQL Server only solution is not unreasonable (is it?).

    It's totally unreasonable if your name is Joe Celko. For the rest of us that actually work with SQL Server on a daily basis, we can be sure that a database will hardly ever be migrated to a different platform, and even then, portability is impossible. The most basic syntax such as creating a table or a stored procedure is different on every system.

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • Why do you need such a long SP code?

    This code will be functionally identical:

    CREATE PROCEDURE [PrepareStageTables]

    (

    @TruncateStage bit

    )

    AS

    IF ( @TruncateStage = 1)

    DELETE [MPNM]

    FROM [NolMatch] AS [MPNM]

    JOIN [Devices] AS [lastload]

    ON [MPNM].[TableID] = [lastload].[TableID]

    WHERE [lastload].[ODSLoadStatus] IS NULL

    OR [ODSLoadStatus] = 'Excluded Model'

    GO

    _____________
    Code for TallyGenerator

  • Luis Cazares - Monday, November 13, 2017 9:17 AM

    nigel. - Monday, November 13, 2017 1:34 AM

    Hmm... looks like the OP has been scared away by all this talk of ISO standards, generic code, etc. 🙂
    The forum does have 'SQL Server' in the title after all. So offering an SQL Server only solution is not unreasonable (is it?).

    It's totally unreasonable if your name is Joe Celko. For the rest of us that actually work with SQL Server on a daily basis, we can be sure that a database will hardly ever be migrated to a different platform, and even then, portability is impossible. The most basic syntax such as creating a table or a stored procedure is different on every system.

    So I am NOT the only one who feels that Joe Celko's ivory tower existence is completely out of touch!  Whew!

  • John N Hick - Tuesday, November 14, 2017 9:12 AM

    Luis Cazares - Monday, November 13, 2017 9:17 AM

    nigel. - Monday, November 13, 2017 1:34 AM

    Hmm... looks like the OP has been scared away by all this talk of ISO standards, generic code, etc. 🙂
    The forum does have 'SQL Server' in the title after all. So offering an SQL Server only solution is not unreasonable (is it?).

    It's totally unreasonable if your name is Joe Celko. For the rest of us that actually work with SQL Server on a daily basis, we can be sure that a database will hardly ever be migrated to a different platform, and even then, portability is impossible. The most basic syntax such as creating a table or a stored procedure is different on every system.

    So I am NOT the only one who feels that Joe Celko's ivory tower existence is completely out of touch!  Whew!

    Frankly, I have difficulty understanding why he's allowed to continue to post here.   I try to ignore him as often as possible.

    Steve (aka sgmunson) 🙂 🙂 🙂
    Rent Servers for Income (picks and shovels strategy)

  • sgmunson - Tuesday, November 14, 2017 9:20 AM

    John N Hick - Tuesday, November 14, 2017 9:12 AM

    Luis Cazares - Monday, November 13, 2017 9:17 AM

    nigel. - Monday, November 13, 2017 1:34 AM

    Hmm... looks like the OP has been scared away by all this talk of ISO standards, generic code, etc. 🙂
    The forum does have 'SQL Server' in the title after all. So offering an SQL Server only solution is not unreasonable (is it?).

    It's totally unreasonable if your name is Joe Celko. For the rest of us that actually work with SQL Server on a daily basis, we can be sure that a database will hardly ever be migrated to a different platform, and even then, portability is impossible. The most basic syntax such as creating a table or a stored procedure is different on every system.

    So I am NOT the only one who feels that Joe Celko's ivory tower existence is completely out of touch!  Whew!

    Frankly, I have difficulty understanding why he's allowed to continue to post here.   I try to ignore him as often as possible.

    He writes some valid points inside his rants from time to time. The problem is that those points go over the head of newbies and are disregarded by people that grew tired of his rants. We could actually adapt a joke to his persona.

    A man in a hot air balloon realized he was lost. He reduced altitudeand spotted a man below. He descended a bit more and shouted,

    "Excuse me, can you help me? I promised a friend I would meet him an hour ago, but I don't know where I am."

    The man below replied, "You are in a hot air balloon hovering approximately 30 feet above the ground. You are between 40 and 41 degrees north latitude and between 59 and 60 degrees west longitude."

    "You must be Joe Celko," said the balloonist.

    "I am," replied the man, "How did you know?"

    "Well," answered the balloonist, "everything you told me is technically correct, but I have no idea what to make of your information, and the fact is I am still lost. Frankly, you've not been much help so far."

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • Luis Cazares - Tuesday, November 14, 2017 10:19 AM

    sgmunson - Tuesday, November 14, 2017 9:20 AM

    John N Hick - Tuesday, November 14, 2017 9:12 AM

    Luis Cazares - Monday, November 13, 2017 9:17 AM

    nigel. - Monday, November 13, 2017 1:34 AM

    Hmm... looks like the OP has been scared away by all this talk of ISO standards, generic code, etc. 🙂
    The forum does have 'SQL Server' in the title after all. So offering an SQL Server only solution is not unreasonable (is it?).

    It's totally unreasonable if your name is Joe Celko. For the rest of us that actually work with SQL Server on a daily basis, we can be sure that a database will hardly ever be migrated to a different platform, and even then, portability is impossible. The most basic syntax such as creating a table or a stored procedure is different on every system.

    So I am NOT the only one who feels that Joe Celko's ivory tower existence is completely out of touch!  Whew!

    Frankly, I have difficulty understanding why he's allowed to continue to post here.   I try to ignore him as often as possible.

    He writes some valid points inside his rants from time to time. The problem is that those points go over the head of newbies and are disregarded by people that grew tired of his rants. We could actually adapt a joke to his persona.

    A man in a hot air balloon realized he was lost. He reduced altitudeand spotted a man below. He descended a bit more and shouted,

    "Excuse me, can you help me? I promised a friend I would meet him an hour ago, but I don't know where I am."

    The man below replied, "You are in a hot air balloon hovering approximately 30 feet above the ground. You are between 40 and 41 degrees north latitude and between 59 and 60 degrees west longitude."

    "You must be Joe Celko," said the balloonist.

    "I am," replied the man, "How did you know?"

    "Well," answered the balloonist, "everything you told me is technically correct, but I have no idea what to make of your information, and the fact is I am still lost. Frankly, you've not been much help so far."

    Then perhaps he can simply serve as a "bad example"...  :hehe:

    Steve (aka sgmunson) 🙂 🙂 🙂
    Rent Servers for Income (picks and shovels strategy)

  • sgmunson - Tuesday, November 14, 2017 10:22 AM

    Luis Cazares - Tuesday, November 14, 2017 10:19 AM

    sgmunson - Tuesday, November 14, 2017 9:20 AM

    John N Hick - Tuesday, November 14, 2017 9:12 AM

    Luis Cazares - Monday, November 13, 2017 9:17 AM

    nigel. - Monday, November 13, 2017 1:34 AM

    Hmm... looks like the OP has been scared away by all this talk of ISO standards, generic code, etc. 🙂
    The forum does have 'SQL Server' in the title after all. So offering an SQL Server only solution is not unreasonable (is it?).

    It's totally unreasonable if your name is Joe Celko. For the rest of us that actually work with SQL Server on a daily basis, we can be sure that a database will hardly ever be migrated to a different platform, and even then, portability is impossible. The most basic syntax such as creating a table or a stored procedure is different on every system.

    So I am NOT the only one who feels that Joe Celko's ivory tower existence is completely out of touch!  Whew!

    Frankly, I have difficulty understanding why he's allowed to continue to post here.   I try to ignore him as often as possible.

    He writes some valid points inside his rants from time to time. The problem is that those points go over the head of newbies and are disregarded by people that grew tired of his rants. We could actually adapt a joke to his persona.

    A man in a hot air balloon realized he was lost. He reduced altitudeand spotted a man below. He descended a bit more and shouted,

    "Excuse me, can you help me? I promised a friend I would meet him an hour ago, but I don't know where I am."

    The man below replied, "You are in a hot air balloon hovering approximately 30 feet above the ground. You are between 40 and 41 degrees north latitude and between 59 and 60 degrees west longitude."

    "You must be Joe Celko," said the balloonist.

    "I am," replied the man, "How did you know?"

    "Well," answered the balloonist, "everything you told me is technically correct, but I have no idea what to make of your information, and the fact is I am still lost. Frankly, you've not been much help so far."

    Then perhaps he can simply serve as a "bad example"...  :hehe:

    Heh... everyone is useful, one way or another. 😉

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

Viewing 11 posts - 16 through 25 (of 25 total)

You must be logged in to reply to this topic. Login to reply