<?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>OpenKB::Server Technical Papers &#187; SQL</title>
	<atom:link href="http://www.openkb.org/category/sql/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.openkb.org</link>
	<description>Computer , server issues and solutions</description>
	<lastBuildDate>Sat, 17 Jul 2010 21:16:22 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>SQL upgrade from MSDE: UpgradeAdvisor returned  -1 .</title>
		<link>http://www.openkb.org/sql-upgrade-from-msde-upgradeadvisor-returned-1/</link>
		<comments>http://www.openkb.org/sql-upgrade-from-msde-upgradeadvisor-returned-1/#comments</comments>
		<pubDate>Wed, 12 May 2010 06:47:40 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[SQL]]></category>

		<guid isPermaLink="false">http://www.openkb.org/?p=786</guid>
		<description><![CDATA[Cause: The error occurs because of a problem with BPACMD.EXE attempting to load BPAClient.dll. While upgrading the instance of SQL Server the setup looks for the BPAClient.dll and it fails as it is not able to find it at C:\Program Files\Microsoft SQL Server\90\Setup Bootstrap\BPA. Solution : Copy the BPAClient.dll file from the following location C:\Program [...]]]></description>
			<content:encoded><![CDATA[<p>Cause:</p>
<p>The error occurs because of a problem with BPACMD.EXE attempting to load BPAClient.dll. While upgrading the instance of SQL Server the setup looks for the BPAClient.dll and it fails as it is not able to find it at C:\Program Files\Microsoft SQL Server\90\Setup Bootstrap\BPA. </p>
<p>Solution :<br />
Copy the BPAClient.dll file from the following location C:\Program Files\Microsoft SQL Server\90\Setup Bootstrap\BPA\bin to C:\Program Files\Microsoft SQL Server\90\Setup Bootstrap\BPA.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.openkb.org/sql-upgrade-from-msde-upgradeadvisor-returned-1/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SQL 2000 &#8211; search all tables</title>
		<link>http://www.openkb.org/sql-2000-search-all-tables/</link>
		<comments>http://www.openkb.org/sql-2000-search-all-tables/#comments</comments>
		<pubDate>Sun, 04 Apr 2010 21:11:13 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[SQL]]></category>

		<guid isPermaLink="false">http://www.openkb.org/?p=765</guid>
		<description><![CDATA[CREATE PROC SearchAllTables ( @SearchStr nvarchar(100) ) AS BEGIN -- Copyright © 2002 Narayana Vyas Kondreddi. All rights reserved. -- Purpose: To search all columns of all tables for a given search string -- Written by: Narayana Vyas Kondreddi -- Site: http://vyaskn.tripod.com -- Tested on: SQL Server 7.0 and SQL Server 2000 -- Date modified: [...]]]></description>
			<content:encoded><![CDATA[<p><code><br />
CREATE PROC SearchAllTables<br />
(<br />
	@SearchStr nvarchar(100)<br />
)<br />
AS<br />
BEGIN</p>
<p>	-- Copyright © 2002 Narayana Vyas Kondreddi. All rights reserved.<br />
	-- Purpose: To search all columns of all tables for a given search string<br />
	-- Written by: Narayana Vyas Kondreddi<br />
	-- Site: http://vyaskn.tripod.com<br />
	-- Tested on: SQL Server 7.0 and SQL Server 2000<br />
	-- Date modified: 28th July 2002 22:50 GMT</p>
<p>	CREATE TABLE #Results (ColumnName nvarchar(370), ColumnValue nvarchar(3630))</p>
<p>	SET NOCOUNT ON</p>
<p>	DECLARE @TableName nvarchar(256), @ColumnName nvarchar(128), @SearchStr2 nvarchar(110)<br />
	SET  @TableName = ''<br />
	SET @SearchStr2 = QUOTENAME('%' + @SearchStr + '%','''')</p>
<p>	WHILE @TableName IS NOT NULL<br />
	BEGIN<br />
		SET @ColumnName = ''<br />
		SET @TableName =<br />
		(<br />
			SELECT MIN(QUOTENAME(TABLE_SCHEMA) + '.' + QUOTENAME(TABLE_NAME))<br />
			FROM 	INFORMATION_SCHEMA.TABLES<br />
			WHERE 		TABLE_TYPE = 'BASE TABLE'<br />
				AND	QUOTENAME(TABLE_SCHEMA) + '.' + QUOTENAME(TABLE_NAME) &gt; @TableName<br />
				AND	OBJECTPROPERTY(<br />
						OBJECT_ID(<br />
							QUOTENAME(TABLE_SCHEMA) + '.' + QUOTENAME(TABLE_NAME)<br />
							 ), 'IsMSShipped'<br />
						       ) = 0<br />
		)</p>
<p>		WHILE (@TableName IS NOT NULL) AND (@ColumnName IS NOT NULL)<br />
		BEGIN<br />
			SET @ColumnName =<br />
			(<br />
				SELECT MIN(QUOTENAME(COLUMN_NAME))<br />
				FROM 	INFORMATION_SCHEMA.COLUMNS<br />
				WHERE 		TABLE_SCHEMA	= PARSENAME(@TableName, 2)<br />
					AND	TABLE_NAME	= PARSENAME(@TableName, 1)<br />
					AND	DATA_TYPE IN ('char', 'varchar', 'nchar', 'nvarchar')<br />
					AND	QUOTENAME(COLUMN_NAME) &gt; @ColumnName<br />
			)</p>
<p>			IF @ColumnName IS NOT NULL<br />
			BEGIN<br />
				INSERT INTO #Results<br />
				EXEC<br />
				(<br />
					'SELECT ''' + @TableName + '.' + @ColumnName + ''', LEFT(' + @ColumnName + ', 3630)<br />
					FROM ' + @TableName + ' (NOLOCK) ' +<br />
					' WHERE ' + @ColumnName + ' LIKE ' + @SearchStr2<br />
				)<br />
			END<br />
		END<br />
	END</p>
<p>	SELECT ColumnName, ColumnValue FROM #Results<br />
END<br />
</code></p>
<p>To execute<br />
EXEC SearchAllTables &#8216;hi mom&#8217;<br />
GO</p>
]]></content:encoded>
			<wfw:commentRss>http://www.openkb.org/sql-2000-search-all-tables/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SQL: attached a mdf without the log file.</title>
		<link>http://www.openkb.org/sql-attached-a-mdf-without-the-log-file/</link>
		<comments>http://www.openkb.org/sql-attached-a-mdf-without-the-log-file/#comments</comments>
		<pubDate>Sat, 20 Feb 2010 01:02:02 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[SQL]]></category>

		<guid isPermaLink="false">http://www.openkb.org/?p=735</guid>
		<description><![CDATA[Missing ldf file Solution You can attach a database without the logfile by attaching, then clicking the logfile location, and click the remove button. After you click OK a new logfile will be created for your database]]></description>
			<content:encoded><![CDATA[<p>Missing ldf file </p>
<p>Solution<br />
You can attach a database without the logfile by attaching, then clicking the logfile location, and click the remove button. After you click OK a new logfile will be created for your database</p>
]]></content:encoded>
			<wfw:commentRss>http://www.openkb.org/sql-attached-a-mdf-without-the-log-file/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>sQL: SQL 2000 truncate logs using DBCC</title>
		<link>http://www.openkb.org/sql-sql-2000-truncate-logs-using-dbcc/</link>
		<comments>http://www.openkb.org/sql-sql-2000-truncate-logs-using-dbcc/#comments</comments>
		<pubDate>Sat, 23 Jan 2010 00:10:37 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[SQL]]></category>

		<guid isPermaLink="false">http://www.openkb.org/?p=720</guid>
		<description><![CDATA[DBCC statememnts act as Database Console commands. You can use the below listed queries, sprcifically the DBCC ones to shrink your transaction log. &#8211; To GET the name of the log and data files select name from dbo.sysfiles &#8211; SEE the active transactions as well as the File ID dbcc loginfo(&#8216;db_Name&#8217;) &#8211; Mark transactions inactive [...]]]></description>
			<content:encoded><![CDATA[<p>DBCC statememnts act as Database Console commands. You can use the below listed queries, sprcifically the DBCC ones to shrink your transaction log.</p>
<p>&#8211; To GET the name of the log and data files<br />
select name from dbo.sysfiles</p>
<p>&#8211; SEE the active transactions as well as the File ID<br />
dbcc loginfo(&#8216;db_Name&#8217;)</p>
<p>&#8211; Mark transactions inactive so that they can be truncated later<br />
&#8211; Suppose file ID is 2</p>
<p>DBCC SHRINKFILE (2)<br />
&#8211; Backup the log file and truncate the inactive entries<br />
BACKUP LOG [db_name] WITH TRUNCATE_ONLY<br />
&#8211; Run Shrinkfile again for maintainence.<br />
DBCC SHRINKFILE (2)</p>
<p>You can create a stored procedure out of the last 3 statements and schedule it as a job on your server than can run overnight and ensure that the transaction log file size does not get out of hand.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.openkb.org/sql-sql-2000-truncate-logs-using-dbcc/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SQL 2008 : Delete all tables in a db</title>
		<link>http://www.openkb.org/sql-2008-delete-all-tables-in-a-db/</link>
		<comments>http://www.openkb.org/sql-2008-delete-all-tables-in-a-db/#comments</comments>
		<pubDate>Fri, 27 Nov 2009 21:10:22 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[SQL]]></category>

		<guid isPermaLink="false">http://www.openkb.org/?p=671</guid>
		<description><![CDATA[Reference EXEC sp_MSforeachtable @command1 = &#8220;DELETE FROM ?&#8221; EXEC sp_MSforeachtable @command1 = &#8220;TRUNCATE TABLE ?&#8221; &#8212;&#8212; You won&#8217;t be able to run TRUNCATE against all tables if you have foreign keys references Here is one way to circumvent that &#8211; First disable referential integrity EXEC sp_MSForEachTable &#8216;ALTER TABLE ? NOCHECK CONSTRAINT ALL&#8217; GO EXEC sp_MSForEachTable [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://social.msdn.microsoft.com/Forums/en-US/transactsql/thread/a512be8a-376f-4fc9-8243-78dbdbe59e55"> Reference </a></p>
<p>EXEC sp_MSforeachtable @command1 = &#8220;DELETE FROM ?&#8221;</p>
<p>EXEC sp_MSforeachtable @command1 = &#8220;TRUNCATE TABLE ?&#8221;</p>
<p>&#8212;&#8212;<br />
You won&#8217;t be able to run TRUNCATE against all tables if you have foreign keys references</p>
<p>Here is one way to circumvent that</p>
<p>&#8211; First disable referential integrity<br />
EXEC sp_MSForEachTable &#8216;ALTER TABLE ? NOCHECK CONSTRAINT ALL&#8217;<br />
GO</p>
<p>EXEC sp_MSForEachTable &#8216;<br />
 IF OBJECTPROPERTY(object_id(&#8221;?&#8221;), &#8221;TableHasForeignRef&#8221;) = 1<br />
  DELETE FROM ?<br />
 else<br />
  TRUNCATE TABLE ?<br />
&#8216;<br />
GO</p>
<p>&#8211; Now enable referential integrity again<br />
EXEC sp_MSForEachTable &#8216;ALTER TABLE ? CHECK CONSTRAINT ALL&#8217;<br />
GO</p>
]]></content:encoded>
			<wfw:commentRss>http://www.openkb.org/sql-2008-delete-all-tables-in-a-db/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SQL: HRESULT 0&#215;80070008</title>
		<link>http://www.openkb.org/sql-hresult-0x80070008/</link>
		<comments>http://www.openkb.org/sql-hresult-0x80070008/#comments</comments>
		<pubDate>Sat, 22 Aug 2009 00:59:23 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[SQL]]></category>

		<guid isPermaLink="false">http://www.openkb.org/?p=580</guid>
		<description><![CDATA[Error: Failed to open malformed assembly &#8216;mscorlib&#8217; with HRESULT 0&#215;80070008. If you are sure your SQL query is correct trying having your webhost restart the SQL server engine. This error could mean the SQL process does not have enough memory to process your request.. other error: There is insufficient system memory in resource pool to [...]]]></description>
			<content:encoded><![CDATA[<p>Error:<br />
Failed to open malformed assembly &#8216;mscorlib&#8217; with HRESULT 0&#215;80070008.</p>
<p>If you are sure your SQL query is correct trying having your webhost restart the SQL server engine. This error could mean the SQL process does not have enough memory to process your request.. </p>
<p>other error:<br />
There is insufficient system memory in resource pool to run this query.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.openkb.org/sql-hresult-0x80070008/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SQL: The DTS Wizard for importing and exporting</title>
		<link>http://www.openkb.org/sql-the-dts-wizard-for-importing-and-exporting/</link>
		<comments>http://www.openkb.org/sql-the-dts-wizard-for-importing-and-exporting/#comments</comments>
		<pubDate>Sun, 26 Jul 2009 19:26:01 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[SQL]]></category>

		<guid isPermaLink="false">http://www.openkb.org/?p=539</guid>
		<description><![CDATA[We found some article relating to the DTS Wizard which is a good tool to use for exporting and importing db structures. so far we have not found the toolkit for SQL 2008 and assume the 2005 version works with 2008. If you have confirmed this please feel free to contact me and correct this [...]]]></description>
			<content:encoded><![CDATA[<p>We found some article relating to the DTS Wizard which is a good tool to use for exporting and importing db structures. </p>
<p>so far we have not found the toolkit for SQL 2008 and assume the 2005 version works with 2008. If you have confirmed this please feel free to <a href="http://www.openkb.org/about/">contact me </a>and correct this information. </p>
<p>You can download the DTS Tool via the 2005 toolkit which can be downloaded from <a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=e8ad606a-0960-4efd-8bd7-b21370c7be2b&#038;DisplayLang=en">Microsoft</a>. </p>
<p>Additional information<br />
<a href="http://connect.microsoft.com/SQLServer/feedback/ViewFeedback.aspx?FeedbackID=331356">Microsoft Connect</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.openkb.org/sql-the-dts-wizard-for-importing-and-exporting/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SQL/ASP: The timeout period elapsed prior to completion</title>
		<link>http://www.openkb.org/sqlasp-the-timeout-period-elapsed-prior-to-completion/</link>
		<comments>http://www.openkb.org/sqlasp-the-timeout-period-elapsed-prior-to-completion/#comments</comments>
		<pubDate>Sat, 16 May 2009 22:54:56 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[ASP]]></category>
		<category><![CDATA[SQL]]></category>

		<guid isPermaLink="false">http://www.openkb.org/?p=483</guid>
		<description><![CDATA[Error: Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding. Try adding a Connect Timeout in the web.config The Connect Timeout attribute of a connection string determines how long a SqlConnection Object runs before it stops attempting to connect to a server. Reference]]></description>
			<content:encoded><![CDATA[<p>Error:<br />
Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding.</p>
<p>Try adding a Connect Timeout in the web.config<br />
<add key="DBConnection" value="server=LocalHost;uid=sa;pwd=;database=DataBaseName;Connect Timeout=200; pooling='true'; Max Pool Size=200"/></p>
<p>The Connect Timeout attribute of a connection string determines how long a SqlConnection Object runs before it stops attempting to connect to a server.</p>
<p><a href="http://forums.asp.net/t/903456.aspx"> Reference </a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.openkb.org/sqlasp-the-timeout-period-elapsed-prior-to-completion/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SQL: drop current connections</title>
		<link>http://www.openkb.org/sql-drop-current-connections/</link>
		<comments>http://www.openkb.org/sql-drop-current-connections/#comments</comments>
		<pubDate>Sun, 10 May 2009 02:00:41 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[SQL]]></category>

		<guid isPermaLink="false">http://www.openkb.org/?p=474</guid>
		<description><![CDATA[You can view the current connections by executing the system proc sp_who2 , if you wish to kill the connection type: kill and the pid number or use ALTER DATABASE &#8216;DATABASE_NAME&#8217; SET SINGLE_USER WITH ROLLBACK_IMMEDIATE.]]></description>
			<content:encoded><![CDATA[<p>You can view the current connections by executing the system proc<br />
sp_who2 , if you wish to kill the connection type: kill and the pid number </p>
<p>or use </p>
<p>ALTER DATABASE &#8216;DATABASE_NAME&#8217; SET SINGLE_USER WITH ROLLBACK_IMMEDIATE.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.openkb.org/sql-drop-current-connections/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SQL: Save (Not Permitted) Dialog Box</title>
		<link>http://www.openkb.org/sql-save-not-permitted-dialog-box/</link>
		<comments>http://www.openkb.org/sql-save-not-permitted-dialog-box/#comments</comments>
		<pubDate>Sat, 21 Mar 2009 18:41:18 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[SQL]]></category>

		<guid isPermaLink="false">http://www.openkb.org/?p=421</guid>
		<description><![CDATA[OMG : Error : The Save (Not Permitted) dialog box warns you that saving changes is not permitted because the changes you have made require the listed tables to be dropped and re-created. The following actions might require a table to be re-created: Adding a new column to the middle of the table Dropping a [...]]]></description>
			<content:encoded><![CDATA[<p>OMG : </p>
<p>Error :<br />
The Save (Not Permitted) dialog box warns you that saving changes is not permitted because the changes you have made require the listed tables to be dropped and re-created.</p>
<p>The following actions might require a table to be re-created:</p>
<p>Adding a new column to the middle of the table<br />
Dropping a column<br />
Changing column nullability<br />
Changing the order of the columns<br />
Changing the data type of a column</p>
<p>Reference: <a href="http://msdn.microsoft.com/en-us/library/bb895146.aspx"> MSDN </a></p>
<p>The user posted a good point on M$ website. what are you suppose to do with the data once the column has been dropped. </p>
<p><strong>Answer: export the data out and back in duh&#8230;</strong>. But this is a stupid security setting.. bad Microsoft&#8230;.</p>
<p>***updated information ********<br />
no words can explain how I am feeling right now .<br />
******************************<br />
Solution:<br />
Within studio management 2008 , you will need to click on tools > options > designers tab > uncheck prevent saving changes that require table re-creation<br />
****************************<br />
Thanks to Henry Cordes for finding this<br />
<a href="http://www.henrycordes.nl/post/2008/11/Saving-changes-is-not-permitted-(SQL-Server-2008).aspx"> Henry Cordes </a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.openkb.org/sql-save-not-permitted-dialog-box/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
