<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
	
	>
<channel>
	<title>
	Comments on: Two ways to find / drop a default constraint without knowing its name	</title>
	<atom:link href="https://lobsterpot.com.au/blog/2007/11/26/two-ways-to-find-drop-a-default-constraint-without-knowing-its-name/feed/" rel="self" type="application/rss+xml" />
	<link>https://lobsterpot.com.au/blog/2007/11/26/two-ways-to-find-drop-a-default-constraint-without-knowing-its-name/</link>
	<description></description>
	<lastBuildDate>Wed, 28 Nov 2007 01:42:22 +0000</lastBuildDate>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.1.2</generator>
	<item>
		<title>
		By: Rob Farley		</title>
		<link>https://lobsterpot.com.au/blog/2007/11/26/two-ways-to-find-drop-a-default-constraint-without-knowing-its-name/#comment-510</link>

		<dc:creator><![CDATA[Rob Farley]]></dc:creator>
		<pubDate>Wed, 28 Nov 2007 01:42:22 +0000</pubDate>
		<guid isPermaLink="false">/blogs/robfarley/archive/2007/11/26/two-ways-to-find-drop-a-default-constraint-without-knowing-its-name.aspx#comment-510</guid>

					<description><![CDATA[Ah, nice tip. Thanks Darren.]]></description>
			<content:encoded><![CDATA[<p>Ah, nice tip. Thanks Darren.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Darren Gosbell		</title>
		<link>https://lobsterpot.com.au/blog/2007/11/26/two-ways-to-find-drop-a-default-constraint-without-knowing-its-name/#comment-509</link>

		<dc:creator><![CDATA[Darren Gosbell]]></dc:creator>
		<pubDate>Tue, 27 Nov 2007 04:00:00 +0000</pubDate>
		<guid isPermaLink="false">/blogs/robfarley/archive/2007/11/26/two-ways-to-find-drop-a-default-constraint-without-knowing-its-name.aspx#comment-509</guid>

					<description><![CDATA[The schema is the issue with the powershell script. I thought I would have been able to pipe the Tables collection to get-member to see it&#039;s methods, but PowerShell was too smart and pulled out the first table so I ended up using reflector to find out that the TableCollection class has an Item() method which has an overload that takes 2 strings, the name and the schema.

So the following should work.

[reflection.assembly]::LoadwithPartialName(&quot;Microsoft.SQLServer.SMO&quot;)
$sql = New-Object &#039;Microsoft.sqlserver.management.smo.server&#039; &#039;localhost&#039;
$sql.Databases[&quot;AdventureWorks&quot;].Tables.Item(&quot;Department&quot;,&quot;HumanResources&quot;).Columns[&quot;ModifiedDate&quot;].DefaultConstraint.Drop()]]></description>
			<content:encoded><![CDATA[<p>The schema is the issue with the powershell script. I thought I would have been able to pipe the Tables collection to get-member to see it&#8217;s methods, but PowerShell was too smart and pulled out the first table so I ended up using reflector to find out that the TableCollection class has an Item() method which has an overload that takes 2 strings, the name and the schema.</p>
<p>So the following should work.</p>
<p>[reflection.assembly]::LoadwithPartialName(&#8220;Microsoft.SQLServer.SMO&#8221;)<br />
$sql = New-Object &#8216;Microsoft.sqlserver.management.smo.server&#8217; &#8216;localhost&#8217;<br />
$sql.Databases[&#8220;AdventureWorks&#8221;].Tables.Item(&#8220;Department&#8221;,&#8221;HumanResources&#8221;).Columns[&#8220;ModifiedDate&#8221;].DefaultConstraint.Drop()</p>
]]></content:encoded>
		
			</item>
	</channel>
</rss>
