<?xml version="1.0" encoding="UTF-8"?>        <rss version="2.0"
             xmlns:atom="http://www.w3.org/2005/Atom"
             xmlns:dc="http://purl.org/dc/elements/1.1/"
             xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
             xmlns:admin="http://webns.net/mvcb/"
             xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
             xmlns:content="http://purl.org/rss/1.0/modules/content/">
        <channel>
            <title>
									CREATE OR ALTER Statement - AugSQL				            </title>
            <link>https://www.augforums.com/forums/augsql/create-or-alter-statement/</link>
            <description>Acumatica User Group Forums</description>
            <language>en-US</language>
            <lastBuildDate>Sat, 07 Nov 2026 11:29:35 +0000</lastBuildDate>
            <generator>wpForo</generator>
            <ttl>60</ttl>
							                    <item>
                        <title>CREATE OR ALTER Statement</title>
                        <link>https://www.augforums.com/forums/augsql/create-or-alter-statement/#post-11219</link>
                        <pubDate>Wed, 20 Mar 2024 14:05:33 +0000</pubDate>
                        <description><![CDATA[I just learned about SQL syntax that apparently has been around since SQL Server 2016.
 
Previously, I would use this SQL code to create a VIEW:
DROP VIEW IF EXISTS dbo.MySQLSystemEvent
...]]></description>
                        <content:encoded><![CDATA[<p>I just learned about SQL syntax that apparently has been around since SQL Server 2016.</p>
<p> </p>
<p>Previously, I would use this SQL code to create a VIEW:</p>
<pre contenteditable="false">DROP VIEW IF EXISTS dbo.MySQLSystemEvent
GO
CREATE VIEW dbo.MySQLSystemEvent AS
SELECT 2 AS CompanyID,ID,TenantName,,,Source,EventID,ScreenID,,Details,Properties
FROM SystemEvent</pre>
<p> </p>
<p>The reason for the first two lines is that I want to be able to run the same SQL Code whether the View already exists or not.</p>
<p>But there are two problems with it:</p>
<p>1. I can never remember the DROP VIEW IF EXISTS... part and always have to Google it.</p>
<p>2. The view gets a new Created date on it which I don't like. I'd like to know the date that the view was originally created.</p>
<p> </p>
<p>Now, with my new discovery (that has existed for 8 year already apparently), I can write this instead:</p>
<pre contenteditable="false">CREATE OR ALTER VIEW dbo.MySQLSystemEvent AS
SELECT 2 AS CompanyID,ID,TenantName,,,Source,EventID,ScreenID,,Details,Properties
FROM SystemEvent</pre>
<p> </p>
<p>This is awesome! It solves both problems:</p>
<p>1. I can remember CREATE OR ALTER without having to Google it.</p>
<p>2. The Created date on the view doesn't change since an ALTER statement gets run if it already exists.</p>
<p> </p>
<p>I love it!</p>]]></content:encoded>
						                            <category domain="https://www.augforums.com/forums/augsql/">AugSQL</category>                        <dc:creator>Tim Rodman</dc:creator>
                        <guid isPermaLink="true">https://www.augforums.com/forums/augsql/create-or-alter-statement/#post-11219</guid>
                    </item>
							        </channel>
        </rss>
		