<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>DDL &#8211; SQLpowered.com</title>
	<atom:link href="https://sqlpowered.com/command-category/ddl/feed/" rel="self" type="application/rss+xml" />
	<link>https://sqlpowered.com</link>
	<description>SQL Server + BI</description>
	<lastBuildDate>Thu, 24 Jul 2025 08:54:48 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	

<image>
	<url>https://sqlpowered.com/wp-content/uploads/2020/07/FavIcon-e1594067873682-99x100.png</url>
	<title>DDL &#8211; SQLpowered.com</title>
	<link>https://sqlpowered.com</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Constraints</title>
		<link>https://sqlpowered.com/t-sql-commands/constraints/</link>
		
		<dc:creator><![CDATA[Jan Dvořák]]></dc:creator>
		<pubDate>Thu, 24 Jul 2025 08:53:22 +0000</pubDate>
				<category><![CDATA[T-SQLpowered]]></category>
		<guid isPermaLink="false">https://sqlpowered.com/?post_type=t-sql-commands&#038;p=5751</guid>

					<description><![CDATA[Add default constraint to column inline: ALTER TABLE [dbo].[SampleTable] ADD Is_Archived BIT NOT NULL CONSTRAINT DF_dbo_Sample_Table_Is_Archived DEFAULT 0 ALTER TABLE [dbo].[SampleTable] ADD Is_Cleaned_Up BIT CONSTRAINT DF_dbo_Sample_Table_Is_Archived DEFAULT 0 NOT NULL &#160;]]></description>
										<content:encoded><![CDATA[<p>Add default constraint to column inline:</p>
<pre class="EnlighterJSRAW" data-enlighter-language="sql">ALTER TABLE [dbo].[SampleTable] ADD Is_Archived BIT NOT NULL CONSTRAINT DF_dbo_Sample_Table_Is_Archived DEFAULT 0 

ALTER TABLE [dbo].[SampleTable] ADD Is_Cleaned_Up BIT CONSTRAINT DF_dbo_Sample_Table_Is_Archived DEFAULT 0 NOT NULL</pre>
<p>&nbsp;</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>CREATE TABLE</title>
		<link>https://sqlpowered.com/t-sql-commands/create-table/</link>
		
		<dc:creator><![CDATA[Jan Dvořák]]></dc:creator>
		<pubDate>Sun, 05 Feb 2023 09:03:40 +0000</pubDate>
				<category><![CDATA[T-SQLpowered]]></category>
		<guid isPermaLink="false">https://sqlpowered.com/?post_type=t-sql-commands&#038;p=5524</guid>

					<description><![CDATA[Create Table with clustered Primary Key on Identity column: CREATE TABLE [dbo].[SampleTable] ( [Id] INT IDENTITY (1,1) NOT NULL, CONSTRAINT [PK_SampleTable] PRIMARY KEY CLUSTERED ([Id]) ) &#160;]]></description>
										<content:encoded><![CDATA[<p>Create Table with clustered Primary Key on Identity column:</p>
<pre class="EnlighterJSRAW" data-enlighter-language="sql">CREATE TABLE [dbo].[SampleTable] (
	[Id] INT IDENTITY (1,1) NOT NULL,
	CONSTRAINT [PK_SampleTable] PRIMARY KEY CLUSTERED ([Id])
)</pre>
<p>&nbsp;</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>ALTER TABLE</title>
		<link>https://sqlpowered.com/t-sql-commands/alter-table/</link>
		
		<dc:creator><![CDATA[Jan Dvořák]]></dc:creator>
		<pubDate>Thu, 30 Dec 2021 08:45:57 +0000</pubDate>
				<category><![CDATA[T-SQLpowered]]></category>
		<guid isPermaLink="false">https://sqlpowered.com/?post_type=t-sql-commands&#038;p=5292</guid>

					<description><![CDATA[Add New Column: ALTER TABLE [dbo].[SampleTable] ADD [NewColum_1] NVARCHAR(MAX) -- will be added as NULLable ALTER TABLE [dbo].[SampleTable] ADD [NewColum_1] NVARCHAR(MAX) NULL ALTER TABLE [dbo].[SampleTable] ADD [NewColum_1] NVARCHAR(MAX) NOT NULL Add Primary Key: ALTER TABLE [dbo].[SampleTable] ADD CONSTRAINT PK_Sample_Table PRIMARY KEY CLUSTERED (Id) Change data type for Primary Key column...]]></description>
										<content:encoded><![CDATA[<p>Add New Column:</p>
<pre class="EnlighterJSRAW" data-enlighter-language="sql">ALTER TABLE [dbo].[SampleTable] ADD [NewColum_1] NVARCHAR(MAX) -- will be added as NULLable
ALTER TABLE [dbo].[SampleTable] ADD [NewColum_1] NVARCHAR(MAX) NULL
ALTER TABLE [dbo].[SampleTable] ADD [NewColum_1] NVARCHAR(MAX) NOT NULL</pre>
<p>Add Primary Key:</p>
<pre class="EnlighterJSRAW" data-enlighter-language="sql">ALTER TABLE [dbo].[SampleTable] ADD CONSTRAINT PK_Sample_Table PRIMARY KEY CLUSTERED (Id)</pre>
<p>Change data type for Primary Key column (IDENTITY setting will be persisted):</p>
<pre class="EnlighterJSRAW" data-enlighter-language="sql">-- drop primary key constraint
ALTER TABLE [dbo].[SampleTable] DROP CONSTRAINT [PK_SampleTable]
GO

-- alter column
ALTER TABLE  [dbo].[SampleTable] ALTER COLUMN [Id] INT NOT NULL -- e.g. changed from SMALLINT to INT

-- recreate primary key constraint
ALTER TABLE [dbo].[SampleTable] ADD CONSTRAINT [PK_SampleTable] PRIMARY KEY CLUSTERED ( [Id] ASC )
GO</pre>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
