<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:pingback="http://madskills.com/public/xml/rss/module/pingback/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0">
  <channel>
    <title>My DasBlog! - SQL Server</title>
    <link>http://net.bloggix.com/</link>
    <description>newtelligence powered</description>
    <language>en-us</language>
    <copyright>Alexander Meijers</copyright>
    <lastBuildDate>Wed, 15 Jun 2005 08:20:19 GMT</lastBuildDate>
    <generator>newtelligence dasBlog 2.3.9074.18820</generator>
    <managingEditor>a.meijers@smoothocean.com</managingEditor>
    <webMaster>a.meijers@smoothocean.com</webMaster>
    <item>
      <trackback:ping>http://net.bloggix.com/Trackback.aspx?guid=fd492fe5-e491-416c-a830-2bb268faabdf</trackback:ping>
      <pingback:server>http://net.bloggix.com/pingback.aspx</pingback:server>
      <pingback:target>http://net.bloggix.com/PermaLink,guid,fd492fe5-e491-416c-a830-2bb268faabdf.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://net.bloggix.com/CommentView,guid,fd492fe5-e491-416c-a830-2bb268faabdf.aspx</wfw:comment>
      <wfw:commentRss>http://net.bloggix.com/SyndicationService.asmx/GetEntryCommentsRss?guid=fd492fe5-e491-416c-a830-2bb268faabdf</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
          <font color="#000000">I got a question from Amit Vasu regarding the installation
of SharePoint Portal Server 2003 with SQL Server versus MSDE. The issue was that
his customer first wanted to use MSDE and if needed later on migrating to SQL
Server.</font>
        </p>
        <p>
          <font color="#000000">This is possible and i did some investigation on MSDN and found
the following. There is an article describing the migration from WMSDE to SQL Server:</font>
        </p>
        <p>
          <a href="http://www.microsoft.com/resources/documentation/wss/2/all/adminguide/en-us/stsf17.mspx">
            <font color="#000000">http://www.microsoft.com/resources/documentation/wss/2/all/adminguide/en-us/stsf17.mspx</font>
          </a>
        </p>
        <p>
          <font color="#000000">After this you have to change the connections in SharePoint
Administration of the databases. the following walkthrough describes it:</font>
        </p>
        <p>
          <font color="#000000">Open the SharePoint Central Administration website and go
to the "Windows SharePoint Services Central Administration". You will find under "Server
Configuration" the option "Set configuration database server". Here you can change
the configuration database to its new location.</font>
        </p>
        <p>
          <font color="#000000">
            <img src="http://blogs.tamtam.nl/alexander/content/binary/database_server_settings.jpg" border="0" />
          </font>
        </p>
        <p>
          <font color="#000000">Go to the "SharePoint Portal Server Central Administration".
You will find under "Server Configuration" the option "Configure server topology".
Here you change the content, component settings and configuration database to their
new location.</font>
        </p>
        <img width="0" height="0" src="http://net.bloggix.com/aggbug.ashx?id=fd492fe5-e491-416c-a830-2bb268faabdf" />
      </body>
      <title>Migrating from WMSDE to SQL Server with SharePoint 2003 Server</title>
      <guid isPermaLink="false">http://net.bloggix.com/PermaLink,guid,fd492fe5-e491-416c-a830-2bb268faabdf.aspx</guid>
      <link>http://net.bloggix.com/2005/06/15/MigratingFromWMSDEToSQLServerWithSharePoint2003Server.aspx</link>
      <pubDate>Wed, 15 Jun 2005 08:20:19 GMT</pubDate>
      <description>&lt;p&gt;
&lt;font color=#000000&gt;I got a question from Amit Vasu&amp;nbsp;regarding the installation
of&amp;nbsp;SharePoint Portal Server 2003 with SQL Server versus MSDE. The issue was that
his customer first wanted to use MSDE and if needed later on migrating&amp;nbsp;to SQL
Server.&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font color=#000000&gt;This is possible and i did some investigation on MSDN and found
the following. There is an article describing the migration from WMSDE to SQL Server:&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://www.microsoft.com/resources/documentation/wss/2/all/adminguide/en-us/stsf17.mspx"&gt;&lt;font color=#000000&gt;http://www.microsoft.com/resources/documentation/wss/2/all/adminguide/en-us/stsf17.mspx&lt;/font&gt;&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font color=#000000&gt;After this you have to change the connections in SharePoint Administration
of the databases. the following walkthrough describes it:&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font color=#000000&gt;Open the SharePoint Central Administration website and&amp;nbsp;go
to the "Windows SharePoint Services Central Administration". You will find under "Server
Configuration"&amp;nbsp;the option "Set configuration database server". Here you can change
the configuration database to its new location.&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font color=#000000&gt;&lt;img src="http://blogs.tamtam.nl/alexander/content/binary/database_server_settings.jpg" border=0&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font color=#000000&gt;Go to the "SharePoint Portal Server Central Administration". You
will find under "Server Configuration" the option "Configure server topology". Here
you change the content, component settings and configuration database to their new
location.&lt;/font&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://net.bloggix.com/aggbug.ashx?id=fd492fe5-e491-416c-a830-2bb268faabdf" /&gt;</description>
      <comments>http://net.bloggix.com/CommentView,guid,fd492fe5-e491-416c-a830-2bb268faabdf.aspx</comments>
      <category>SharePoint</category>
      <category>SQL Server</category>
    </item>
    <item>
      <trackback:ping>http://net.bloggix.com/Trackback.aspx?guid=0b082ef3-9c3b-44d6-a027-af3d69aed4d4</trackback:ping>
      <pingback:server>http://net.bloggix.com/pingback.aspx</pingback:server>
      <pingback:target>http://net.bloggix.com/PermaLink,guid,0b082ef3-9c3b-44d6-a027-af3d69aed4d4.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://net.bloggix.com/CommentView,guid,0b082ef3-9c3b-44d6-a027-af3d69aed4d4.aspx</wfw:comment>
      <wfw:commentRss>http://net.bloggix.com/SyndicationService.asmx/GetEntryCommentsRss?guid=0b082ef3-9c3b-44d6-a027-af3d69aed4d4</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
          <font color="#000000">Its very cool when you debug T-SQL in Visual Studio .NET. Just
step from your code into a stored procedure in the SQL Server database. I found some
articles at Microsoft about T-SQL Debugging in Visual Studio .NET which could be helpfull
to setup your environment.</font>
        </p>
        <p>
          <font color="#000000">
            <strong>Setting Up SQL Debugging<br /></strong>
          </font>
          <a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vsdebug/html/vxlrfsettingupsqldebugging.asp">
            <font color="#808080">http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vsdebug/html/vxlrfsettingupsqldebugging.asp</font>
          </a>
        </p>
        <p>
          <font color="#000000">
            <strong>Enabling SQL Debugging<br /></strong>
          </font>
          <a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vsdebug/html/vxlrfsettingupsqldebuggingenablingsqldebugging.asp">
            <font color="#808080">http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vsdebug/html/vxlrfsettingupsqldebuggingenablingsqldebugging.asp</font>
          </a>
        </p>
        <p>
          <font color="#000000">
            <strong>Troubleshooting tips for T-SQL Debugger in Visual Studio
.NET</strong>
            <br />
          </font>
          <a href="http://support.microsoft.com/default.aspx?scid=kb;en-us;817178&amp;Product=sql">
            <font color="#808080">http://support.microsoft.com/default.aspx?scid=kb;en-us;817178&amp;Product=sql</font>
          </a>
        </p>
        <p>
          <font color="#000000">
            <strong>SQL Debugging: Unable to Start SQL Debug Session</strong>
            <br />
          </font>
          <a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vsdebug/html/vxtbstroubleshootingsqldebuggingsetuperrormessageunabletostartsqldebugsession.asp">
            <font color="#808080">http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vsdebug/html/vxtbstroubleshootingsqldebuggingsetu<br />
perrormessageunabletostartsqldebugsession.asp</font>
          </a>
        </p>
        <p>
          <font color="#000000">If you know any other articles about T-SQL Debugging please
don't hesitate to give a comment on this post. I will put it into the list. :)</font>
        </p>
        <img width="0" height="0" src="http://net.bloggix.com/aggbug.ashx?id=0b082ef3-9c3b-44d6-a027-af3d69aed4d4" />
      </body>
      <title>T-SQL Debugging in Visual Studio .NET</title>
      <guid isPermaLink="false">http://net.bloggix.com/PermaLink,guid,0b082ef3-9c3b-44d6-a027-af3d69aed4d4.aspx</guid>
      <link>http://net.bloggix.com/2005/05/26/TSQLDebuggingInVisualStudioNET.aspx</link>
      <pubDate>Thu, 26 May 2005 07:00:30 GMT</pubDate>
      <description>&lt;p&gt;
&lt;font color=#000000&gt;Its very cool when you debug T-SQL in Visual Studio .NET. Just
step from your code into a stored procedure in the SQL Server database. I found some
articles at Microsoft about T-SQL Debugging in Visual Studio .NET which could be helpfull
to setup your environment.&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font color=#000000&gt;&lt;strong&gt;Setting Up SQL Debugging&lt;br&gt;
&lt;/strong&gt;&lt;/font&gt;&lt;a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vsdebug/html/vxlrfsettingupsqldebugging.asp"&gt;&lt;font color=#808080&gt;http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vsdebug/html/vxlrfsettingupsqldebugging.asp&lt;/font&gt;&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font color=#000000&gt;&lt;strong&gt;Enabling SQL Debugging&lt;br&gt;
&lt;/strong&gt;&lt;/font&gt;&lt;a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vsdebug/html/vxlrfsettingupsqldebuggingenablingsqldebugging.asp"&gt;&lt;font color=#808080&gt;http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vsdebug/html/vxlrfsettingupsqldebuggingenablingsqldebugging.asp&lt;/font&gt;&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font color=#000000&gt;&lt;strong&gt;Troubleshooting tips for T-SQL Debugger in Visual Studio
.NET&lt;/strong&gt;
&lt;br&gt;
&lt;/font&gt;&lt;a href="http://support.microsoft.com/default.aspx?scid=kb;en-us;817178&amp;amp;Product=sql"&gt;&lt;font color=#808080&gt;http://support.microsoft.com/default.aspx?scid=kb;en-us;817178&amp;amp;Product=sql&lt;/font&gt;&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font color=#000000&gt;&lt;strong&gt;SQL Debugging: Unable to Start SQL Debug Session&lt;/strong&gt;
&lt;br&gt;
&lt;/font&gt;&lt;a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vsdebug/html/vxtbstroubleshootingsqldebuggingsetuperrormessageunabletostartsqldebugsession.asp"&gt;&lt;font color=#808080&gt;http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vsdebug/html/vxtbstroubleshootingsqldebuggingsetu&lt;br&gt;
perrormessageunabletostartsqldebugsession.asp&lt;/font&gt;&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font color=#000000&gt;If you know any other articles about T-SQL Debugging please don't
hesitate to give a comment on this post. I will put it into the list. :)&lt;/font&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://net.bloggix.com/aggbug.ashx?id=0b082ef3-9c3b-44d6-a027-af3d69aed4d4" /&gt;</description>
      <comments>http://net.bloggix.com/CommentView,guid,0b082ef3-9c3b-44d6-a027-af3d69aed4d4.aspx</comments>
      <category>.NET</category>
      <category>SQL Server</category>
    </item>
    <item>
      <trackback:ping>http://net.bloggix.com/Trackback.aspx?guid=ef822f4b-0f70-4cb9-afb7-e2e5099e01e1</trackback:ping>
      <pingback:server>http://net.bloggix.com/pingback.aspx</pingback:server>
      <pingback:target>http://net.bloggix.com/PermaLink,guid,ef822f4b-0f70-4cb9-afb7-e2e5099e01e1.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://net.bloggix.com/CommentView,guid,ef822f4b-0f70-4cb9-afb7-e2e5099e01e1.aspx</wfw:comment>
      <wfw:commentRss>http://net.bloggix.com/SyndicationService.asmx/GetEntryCommentsRss?guid=ef822f4b-0f70-4cb9-afb7-e2e5099e01e1</wfw:commentRss>
      <slash:comments>2</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
          <font color="#000000">Passing a null value to an int is not possible. The int type
is mapped to the System.Int32 structure type and is not capable of storing a null
value. Only integer values can be stored in there.</font>
        </p>
        <p>
          <font color="#000000">There are two ways which i know of how to solve this problem.
The first method is using an object in stead of the int type. For example:</font>
        </p>
        <p>
          <font face="Courier New" color="#808080">object val = 200;</font>
        </p>
        <p>
          <font face="Courier New" color="#808080">if (val != null)<br />
{<br />
   return (int)val;<br />
}<br /></font>
          <br />
          <font color="#000000">In this way you can set the <font face="Courier New" color="#808080">val</font> variable
to a null value or an integer value. In case of an integer value you unbox the value
to retrieve the integer value.</font>
        </p>
        <p>
          <font color="#000000">A second method is using the <font face="Courier New" color="#808080">SqlInt32</font> type
found in namespace <font face="Courier New" color="#808080">System.Data.SqlTypes</font> which
is a SQL type. This type supports nullable values. For example:</font>
        </p>
        <p>
          <font color="#808080">
            <font face="Courier New">SqlInt32 val = SqlInt32.Null;</font>
          </font>
        </p>
        <p>
          <font color="#000000">or</font>
        </p>
        <p>
          <font face="Courier New" color="#808080">SqlInt32 val = 200;</font>
        </p>
        <img width="0" height="0" src="http://net.bloggix.com/aggbug.ashx?id=ef822f4b-0f70-4cb9-afb7-e2e5099e01e1" />
      </body>
      <title>Passing a null value to an int in .NET</title>
      <guid isPermaLink="false">http://net.bloggix.com/PermaLink,guid,ef822f4b-0f70-4cb9-afb7-e2e5099e01e1.aspx</guid>
      <link>http://net.bloggix.com/2005/05/17/PassingANullValueToAnIntInNET.aspx</link>
      <pubDate>Tue, 17 May 2005 09:42:58 GMT</pubDate>
      <description>&lt;p&gt;
&lt;font color=#000000&gt;Passing a null value to an int is not possible. The int type is
mapped to the System.Int32 structure type and is not capable of storing a null value.
Only integer values can be stored in there.&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font color=#000000&gt;There are two ways which i know of how to solve this problem.
The first method is using an object in stead of the int type. For example:&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New" color=#808080&gt;object val = 200;&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New" color=#808080&gt;if (val != null)&lt;br&gt;
{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;return (int)val;&lt;br&gt;
}&lt;br&gt;
&lt;/font&gt;
&lt;br&gt;
&lt;font color=#000000&gt;In this way you can set the &lt;font face="Courier New" color=#808080&gt;val&lt;/font&gt; variable
to a null value or an integer value. In case of an integer value you unbox the value
to retrieve the integer value.&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font color=#000000&gt;A second method is using the &lt;font face="Courier New" color=#808080&gt;SqlInt32&lt;/font&gt; type
found in namespace&amp;nbsp;&lt;font face="Courier New" color=#808080&gt;System.Data.SqlTypes&lt;/font&gt; which
is a SQL type. This type supports nullable values. For example:&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font color=#808080&gt;&lt;font face="Courier New"&gt;SqlInt32 val = SqlInt32.Null;&lt;/font&gt; &lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font color=#000000&gt;or&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New" color=#808080&gt;SqlInt32 val = 200;&lt;/font&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://net.bloggix.com/aggbug.ashx?id=ef822f4b-0f70-4cb9-afb7-e2e5099e01e1" /&gt;</description>
      <comments>http://net.bloggix.com/CommentView,guid,ef822f4b-0f70-4cb9-afb7-e2e5099e01e1.aspx</comments>
      <category>C#</category>
      <category>SQL Server</category>
    </item>
    <item>
      <trackback:ping>http://net.bloggix.com/Trackback.aspx?guid=ba293acd-b66e-40b0-a4d7-d123b1ed131e</trackback:ping>
      <pingback:server>http://net.bloggix.com/pingback.aspx</pingback:server>
      <pingback:target>http://net.bloggix.com/PermaLink,guid,ba293acd-b66e-40b0-a4d7-d123b1ed131e.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://net.bloggix.com/CommentView,guid,ba293acd-b66e-40b0-a4d7-d123b1ed131e.aspx</wfw:comment>
      <wfw:commentRss>http://net.bloggix.com/SyndicationService.asmx/GetEntryCommentsRss?guid=ba293acd-b66e-40b0-a4d7-d123b1ed131e</wfw:commentRss>
      <slash:comments>1</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
I needed some tool to look for keywords, texts or other things by searching through
all fields of all columns of all tables of a specific database.
</p>
        <p>
I found an <a href="http://vyaskn.tripod.com/search_all_columns_in_all_tables.htm">article</a> written
by <a href="http://vyaskn.tripod.com/">Vyas</a> were he writes about a stored
procedure which searches through all tables of the database it is created in.
</p>
        <p>
It accepts a search string as input parameter, goes and searches all char, varchar,
nchar, nvarchar columns of all tables (only user created tables. System tables are
excluded), owned by all users in the current database. 
</p>
        <p>
          <br />
The output of this stored procedure contains two columns: 
<br /><br />
- 1) The table name and column name in which the search string was found 
<br />
- 2) The actual content/value of the column (Only the first 3630 characters are displayed) 
<br /><br />
Here's a word of caution, before you go ahead and run this procedure. Though this
procedure is quite quick on smaller databases, it could take hours to complete, on
a large database with too many character columns and a huge number of rows. So, if
you are trying to run it on a large database, be prepared to wait (I did use the locking
hint NOLOCK to reduce any locking). It is efficient to use Full-Text search feature
for free text searching, but it doesn't make sense for this type of ad-hoc requirements. 
<br /><br />
Create this procedure in the required database and here is how you run it:<br /><br /><font face="verdana" color="gray" size="2">--To search all columns of all tables in
Pubs database for the keyword "Computer"</font><br /><font face="verdana" color="blue" size="2">EXEC SearchAllTables 'Computer'<br />
GO</font><br /><br />
Here is the complete stored procedure code: 
</p>
        <pre>
          <font face="verdana" color="blue" size="1"> CREATE PROC SearchAllTables ( @SearchStr
nvarchar(100) ) AS BEGIN <font face="verdana" color="gray" size="1"> -- 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: 28th July 2002 22:50 GMT </font> CREATE TABLE #Results (ColumnName
nvarchar(370), ColumnValue nvarchar(3630)) SET NOCOUNT ON DECLARE @TableName nvarchar(256),
@ColumnName nvarchar(128), @SearchStr2 nvarchar(110) SET @TableName = '' SET @SearchStr2
= QUOTENAME('%' + @SearchStr + '%','''') WHILE @TableName IS NOT NULL BEGIN SET @ColumnName
= '' SET @TableName = ( SELECT MIN(QUOTENAME(TABLE_SCHEMA) + '.' + QUOTENAME(TABLE_NAME))
FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE = 'BASE TABLE' AND QUOTENAME(TABLE_SCHEMA)
+ '.' + QUOTENAME(TABLE_NAME) &gt; @TableName AND OBJECTPROPERTY( OBJECT_ID( QUOTENAME(TABLE_SCHEMA)
+ '.' + QUOTENAME(TABLE_NAME) ), 'IsMSShipped' ) = 0 ) WHILE (@TableName IS NOT NULL)
AND (@ColumnName IS NOT NULL) BEGIN SET @ColumnName = ( SELECT MIN(QUOTENAME(COLUMN_NAME))
FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = PARSENAME(@TableName, 2) AND
TABLE_NAME = PARSENAME(@TableName, 1) AND DATA_TYPE IN ('char', 'varchar', 'nchar',
'nvarchar') AND QUOTENAME(COLUMN_NAME) &gt; @ColumnName ) IF @ColumnName IS NOT NULL
BEGIN INSERT INTO #Results EXEC ( 'SELECT ''' + @TableName + '.' + @ColumnName + ''',
LEFT(' + @ColumnName + ', 3630) FROM ' + @TableName + ' (NOLOCK) ' + ' WHERE ' + @ColumnName
+ ' LIKE ' + @SearchStr2 ) END END END SELECT ColumnName, ColumnValue FROM #Results
END </font>
        </pre>
        <img width="0" height="0" src="http://net.bloggix.com/aggbug.ashx?id=ba293acd-b66e-40b0-a4d7-d123b1ed131e" />
      </body>
      <title>How to search all columns of all tables in a database for a keyword</title>
      <guid isPermaLink="false">http://net.bloggix.com/PermaLink,guid,ba293acd-b66e-40b0-a4d7-d123b1ed131e.aspx</guid>
      <link>http://net.bloggix.com/2005/04/21/HowToSearchAllColumnsOfAllTablesInADatabaseForAKeyword.aspx</link>
      <pubDate>Thu, 21 Apr 2005 12:28:42 GMT</pubDate>
      <description>&lt;p&gt;
I needed some tool to look for keywords, texts or other things&amp;nbsp;by searching through
all fields of all columns of all&amp;nbsp;tables of a specific database.
&lt;/p&gt;
&lt;p&gt;
I found an &lt;a href="http://vyaskn.tripod.com/search_all_columns_in_all_tables.htm"&gt;article&lt;/a&gt;&amp;nbsp;written
by&amp;nbsp;&lt;a href="http://vyaskn.tripod.com/"&gt;Vyas&lt;/a&gt; were he&amp;nbsp;writes about a&amp;nbsp;stored
procedure which searches through all tables of the database it is created in.
&lt;/p&gt;
&lt;p&gt;
It accepts a search string as input parameter, goes and searches all char, varchar,
nchar, nvarchar columns of all tables (only user created tables. System tables are
excluded), owned by all users in the current database. 
&lt;/p&gt;
&lt;p&gt;
&lt;br&gt;
The output of this stored procedure contains two columns: 
&lt;br&gt;
&lt;br&gt;
- 1) The table name and column name in which the search string was found 
&lt;br&gt;
- 2) The actual content/value of the column (Only the first 3630 characters are displayed) 
&lt;br&gt;
&lt;br&gt;
Here's a word of caution, before you go ahead and run this procedure. Though this
procedure is quite quick on smaller databases, it could take hours to complete, on
a large database with too many character columns and a huge number of rows. So, if
you are trying to run it on a large database, be prepared to wait (I did use the locking
hint NOLOCK to reduce any locking). It is efficient to use Full-Text search feature
for free text searching, but it doesn't make sense for this type of ad-hoc requirements. 
&lt;br&gt;
&lt;br&gt;
Create this procedure in the required database and here is how you run it:&lt;br&gt;
&lt;br&gt;
&lt;font face=verdana color=gray size=2&gt;--To search all columns of all tables in Pubs
database for the keyword "Computer"&lt;/font&gt; 
&lt;br&gt;
&lt;font face=verdana color=blue size=2&gt;EXEC SearchAllTables 'Computer'&lt;br&gt;
GO&lt;/font&gt; 
&lt;br&gt;
&lt;br&gt;
Here is the complete stored procedure code: 
&lt;/p&gt;
&lt;pre&gt;&lt;font face=verdana color=blue size=1&gt; CREATE PROC SearchAllTables ( @SearchStr
nvarchar(100) ) AS BEGIN &lt;font face=verdana color=gray size=1&gt; -- 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: 28th July 2002 22:50 GMT &lt;/font&gt; CREATE TABLE #Results (ColumnName nvarchar(370),
ColumnValue nvarchar(3630)) SET NOCOUNT ON DECLARE @TableName nvarchar(256), @ColumnName
nvarchar(128), @SearchStr2 nvarchar(110) SET @TableName = '' SET @SearchStr2 = QUOTENAME('%'
+ @SearchStr + '%','''') WHILE @TableName IS NOT NULL BEGIN SET @ColumnName = '' SET
@TableName = ( SELECT MIN(QUOTENAME(TABLE_SCHEMA) + '.' + QUOTENAME(TABLE_NAME)) FROM
INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE = 'BASE TABLE' AND QUOTENAME(TABLE_SCHEMA)
+ '.' + QUOTENAME(TABLE_NAME) &amp;gt; @TableName AND OBJECTPROPERTY( OBJECT_ID( QUOTENAME(TABLE_SCHEMA)
+ '.' + QUOTENAME(TABLE_NAME) ), 'IsMSShipped' ) = 0 ) WHILE (@TableName IS NOT NULL)
AND (@ColumnName IS NOT NULL) BEGIN SET @ColumnName = ( SELECT MIN(QUOTENAME(COLUMN_NAME))
FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = PARSENAME(@TableName, 2) AND
TABLE_NAME = PARSENAME(@TableName, 1) AND DATA_TYPE IN ('char', 'varchar', 'nchar',
'nvarchar') AND QUOTENAME(COLUMN_NAME) &amp;gt; @ColumnName ) IF @ColumnName IS NOT NULL
BEGIN INSERT INTO #Results EXEC ( 'SELECT ''' + @TableName + '.' + @ColumnName + ''',
LEFT(' + @ColumnName + ', 3630) FROM ' + @TableName + ' (NOLOCK) ' + ' WHERE ' + @ColumnName
+ ' LIKE ' + @SearchStr2 ) END END END SELECT ColumnName, ColumnValue FROM #Results
END &lt;/font&gt;&lt;/pre&gt;&lt;img width="0" height="0" src="http://net.bloggix.com/aggbug.ashx?id=ba293acd-b66e-40b0-a4d7-d123b1ed131e" /&gt;</description>
      <comments>http://net.bloggix.com/CommentView,guid,ba293acd-b66e-40b0-a4d7-d123b1ed131e.aspx</comments>
      <category>SQL Server</category>
    </item>
    <item>
      <trackback:ping>http://net.bloggix.com/Trackback.aspx?guid=798347a6-5333-4294-8d57-67cbec3fd0fc</trackback:ping>
      <pingback:server>http://net.bloggix.com/pingback.aspx</pingback:server>
      <pingback:target>http://net.bloggix.com/PermaLink,guid,798347a6-5333-4294-8d57-67cbec3fd0fc.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://net.bloggix.com/CommentView,guid,798347a6-5333-4294-8d57-67cbec3fd0fc.aspx</wfw:comment>
      <wfw:commentRss>http://net.bloggix.com/SyndicationService.asmx/GetEntryCommentsRss?guid=798347a6-5333-4294-8d57-67cbec3fd0fc</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Yesterday was one of those days.... I was working on a project and doing a lot of
debugging in SharePoint. At some point the system crashed and I had to reboot. After
rebooting the computer it seems that my master database in SQL Server was crashed. 
</p>
        <p>
Ofcourse i did not made any backups of the master database. :(
</p>
        <p>
I finally decided to copy all the mdf and ldf files from the data folder to another
folder and deinstalled SQL Server. After reinstalling SQL Server i created the databases
which ofcourse created the default mdf and ldf files. Then i copied the earlier copied files
back over the just created mdf and ldf files. Do'nt forget to stop the SQL Server
otherwise it will complain about in use files. I was very suprised to see that
my databases returned including the data after starting SQL Server again.
</p>
        <p>
It also seems that doing this will update the master database automatically. In my
case i'm working with SQL Server 2000. I'm not sure if this also works for earlier
versions. 
</p>
        <p>
Another problem arised because the rights which were set by programs like SharePoint
when they create the database were gone. So it will not work in every case.
</p>
        <p>
Later on i came to the conclusion that if i only had overwritten the master database
files (mdf and ldf) with those of a clean install of SQL Server, after restarting
SQL Server everything could work again. I still have to try this.
</p>
        <p>
Hope this helps in case your master database gets corrupt.
</p>
        <img width="0" height="0" src="http://net.bloggix.com/aggbug.ashx?id=798347a6-5333-4294-8d57-67cbec3fd0fc" />
      </body>
      <title>Fixing corrupt master database in SQL Server 2000</title>
      <guid isPermaLink="false">http://net.bloggix.com/PermaLink,guid,798347a6-5333-4294-8d57-67cbec3fd0fc.aspx</guid>
      <link>http://net.bloggix.com/2005/03/24/FixingCorruptMasterDatabaseInSQLServer2000.aspx</link>
      <pubDate>Thu, 24 Mar 2005 07:33:27 GMT</pubDate>
      <description>&lt;p&gt;
Yesterday was one of those days.... I was working on a project and doing a lot of
debugging in SharePoint. At some point the system crashed and I had to reboot. After
rebooting the computer it seems that my master database in SQL Server&amp;nbsp;was crashed. 
&lt;/p&gt;
&lt;p&gt;
Ofcourse i did not made any backups of the master database. :(
&lt;/p&gt;
&lt;p&gt;
I finally decided to copy all the mdf and ldf files from the data folder to another
folder and deinstalled SQL Server. After reinstalling SQL Server i created the databases
which ofcourse created the default mdf and ldf files. Then i copied the earlier copied&amp;nbsp;files
back over the just created mdf and ldf files. Do'nt forget to stop the SQL Server
otherwise it will complain about in use files.&amp;nbsp;I was very suprised to see that
my databases returned including the data after starting SQL Server again.
&lt;/p&gt;
&lt;p&gt;
It also seems that doing this will update the master database automatically. In my
case i'm working with SQL Server 2000. I'm not sure if this also works for earlier
versions. 
&lt;/p&gt;
&lt;p&gt;
Another problem arised because the rights which were set by programs like SharePoint
when they create the database were gone. So it will not work in every case.
&lt;/p&gt;
&lt;p&gt;
Later on i came to the conclusion that if i only had overwritten the master database
files (mdf and ldf) with those of a clean install of SQL Server, after restarting
SQL Server everything could work again. I still have to try this.
&lt;/p&gt;
&lt;p&gt;
Hope this helps in case your master database gets corrupt.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://net.bloggix.com/aggbug.ashx?id=798347a6-5333-4294-8d57-67cbec3fd0fc" /&gt;</description>
      <comments>http://net.bloggix.com/CommentView,guid,798347a6-5333-4294-8d57-67cbec3fd0fc.aspx</comments>
      <category>SQL Server</category>
    </item>
  </channel>
</rss>