<?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>Thu, 02 Feb 2012 16:50:15 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>SQL: Can not create worker thread</title>
		<link>http://www.openkb.org/sql-can-not-create-worker-thread/</link>
		<comments>http://www.openkb.org/sql-can-not-create-worker-thread/#comments</comments>
		<pubDate>Sun, 24 Jul 2011 07:17:15 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[SQL]]></category>

		<guid isPermaLink="false">http://www.openkb.org/?p=1003</guid>
		<description><![CDATA[Error: Can not create worker thread Check the Server load and restart the SQL engine]]></description>
			<content:encoded><![CDATA[<p>Error: Can not create worker thread</p>
<p>Check the Server load and restart the SQL engine </p>
]]></content:encoded>
			<wfw:commentRss>http://www.openkb.org/sql-can-not-create-worker-thread/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SQL: Cannot drop the user dbo</title>
		<link>http://www.openkb.org/sql-cannot-drop-the-user-dbo/</link>
		<comments>http://www.openkb.org/sql-cannot-drop-the-user-dbo/#comments</comments>
		<pubDate>Sun, 17 Apr 2011 10:08:50 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[SQL]]></category>

		<guid isPermaLink="false">http://www.openkb.org/?p=946</guid>
		<description><![CDATA[Error: Cannot drop the user &#8216;dbo&#8217;. (Microsoft SQL Server, Error: 15150) Problem: trying to unmapped a user to a database , you may receive the above error message. This is because the dbo user is assigned the login of the user you are trying to remove. You will need to run the following query to [...]]]></description>
			<content:encoded><![CDATA[<p>Error:<br />
Cannot drop the user &#8216;dbo&#8217;. (Microsoft SQL Server, Error: 15150)</p>
<p>Problem: trying to unmapped a user to a database , you may receive the above error message. This is because the dbo user is assigned the login of the user you are trying to remove. You will need to run the following query to change the user  </p>
<p>exec sp_changedbowner &#8216;new user&#8217;</p>
<p>or if this is part of Active directory </p>
<p>exec sp_changedbowner &#8216;domain\user&#8217;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.openkb.org/sql-cannot-drop-the-user-dbo/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SQL 2008: clearing current connections</title>
		<link>http://www.openkb.org/sql-2008-clearing-current-connections/</link>
		<comments>http://www.openkb.org/sql-2008-clearing-current-connections/#comments</comments>
		<pubDate>Sun, 27 Mar 2011 10:46:35 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[SQL]]></category>

		<guid isPermaLink="false">http://www.openkb.org/?p=944</guid>
		<description><![CDATA[You can clear the current SQL connections by issuing the following query USE master; GO ALTER DATABASE dbName SET SINGLE_USER WITH ROLLBACK IMMEDIATE; GO ALTER DATABASE dbName SET MULTI_USER; GO]]></description>
			<content:encoded><![CDATA[<p>You can clear the current SQL connections by issuing the following query</p>
<p><code><br />
USE master;<br />
GO<br />
ALTER DATABASE dbName<br />
SET SINGLE_USER<br />
WITH ROLLBACK IMMEDIATE;<br />
GO<br />
ALTER DATABASE dbName<br />
SET MULTI_USER;<br />
GO<br />
</code></p>
]]></content:encoded>
			<wfw:commentRss>http://www.openkb.org/sql-2008-clearing-current-connections/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>asp.net: Cannot find table 0</title>
		<link>http://www.openkb.org/asp-net-cannot-find-table-0/</link>
		<comments>http://www.openkb.org/asp-net-cannot-find-table-0/#comments</comments>
		<pubDate>Tue, 21 Dec 2010 22:44:53 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[ASP]]></category>
		<category><![CDATA[SQL]]></category>

		<guid isPermaLink="false">http://www.openkb.org/?p=905</guid>
		<description><![CDATA[Error: Exception Details: System.IndexOutOfRangeException: Cannot find table 0. Possible Solution: I am sure there are a few solutions for this error, but the one we encountered was related to the web.config file being incorrect. The database information was invalid. Hopefully this will help someone who encounters the same isue]]></description>
			<content:encoded><![CDATA[<p>Error:<br />
Exception Details: System.IndexOutOfRangeException: Cannot find table 0.</p>
<p>Possible Solution:<br />
I am sure there are a few solutions for this error, but the one we encountered was related to the web.config file being incorrect. The database information was invalid. Hopefully this will help someone who encounters the same isue </p>
]]></content:encoded>
			<wfw:commentRss>http://www.openkb.org/asp-net-cannot-find-table-0/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<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>
	</channel>
</rss>

