While watching a web cast by John Weston, I noticed a very important thing which is the clarification of what is not Data Mining? It is very common that people sometime get confused with what actually is Data Mining and start referring different terms and techniques used in normal data processing as Data Mining activities.
Following is a list which describes different data processing techniques and why they can not be reffered as Data Mining?
1. Ad Hoc Query:
Ad Hoc queries just examines the current data set and gives you result based on that. This means you can check what is the maximum price of a product but you can not predict what will be the maximum price of that product in near future? A Data Mining Algorithm can do it.
2. Event Notification:
You can set different alerts based on some threshold values which will inform you as soon as that threshold will reach by actual transactional data but again you can not predict when that threshold will reach? A Data Mining Algorithm can do it.
3. Multidimensional Analysis:
You can find the value of an item based on different dimensions like Time, Area, Color but you can not predict what will be the value of the item when its color will be Blue and Area will be UK and Time will be First Quarter of the year? A Data Mining Algorithm can do it.
4. Statistics:
Item Statistics can tell you the history of price changes, moving averages, maximum values, minimum values etc. but it can not tell you how price will change if you start selling another product in the same season. A Data Mining Algorithm can do it.
So in simple words…Data Mining is not history…It is Future!
If you are trying to install SQL Server 2005 client tools and continuously getting failure message because of MSXML 6 installation which already exists on your machine then it may be due to the corrupted installation of MSXML 6 which blocks the installation of client tools. You can fix it as follows:
Go to Control Panel-> Administrative Tools->Add Remove Programs and try to remove it. If it removes smoothly then just install the Client Tools as before and you are done.
OR
If you found that you are unable to uninstall the MSXML 6 because of some wiered error then you need a tool called Windows Install Clean up from here
Donwload it and remove the corrupt installation of MSXML 6. Once removed, you can now install the Client tools as usual.
Custom database roles is the best way to manage object permission for the given database in structured way. Following script will demonstrate the steps necessary to create a new role and manage object permissions through it
--- Step 1 -------- Create Role ------------
USE [MyTestDB]
GO
CREATE ROLE [TestRole1] AUTHORIZATION [dbo]
Go
--- Step 2 -------- Assign Permissions to role ------------
USE [MyTestDB]
GO
GRANT ALTER,EXECUTE, SELECT,INSERT,UPDATE,DELETE
ON SCHEMA ::dbo
TO TestRole1
Go
USE [MyTestDB]
GO
GRANT BACKUP DATABASE,BACKUP LOG To [TestRole1]
Go
--- Step 3 ---- Add user to our role --------------
USE [MyTestDB]
GO
EXEC sp_addrolemember N'TestRole1', N'SPUser7'
GO
-- ****** Create user *********************
--- Step 1 ---- Create Windows Login For SQL Server ------------
USE [master]
GO
CREATE LOGIN [TestDomain\SPUser7] FROM WINDOWS WITH DEFAULT_DATABASE=[MyTestDB]
GO
--- Step 2 ---- Create Database User for our database --------------
USE [MyTestDB]
GO
CREATE USER [SPUser7] FOR LOGIN [TestDomain\SPUser7]
GO
While browsing through the Sharepoint content database, I found a very useful TSQL utility function which can be used in any application. This function encodes the given html so that it can be safely used in XML tags and other html rendering requirements.
Please note, this function is originally provided in Sharepoint content database and I have just copied it because of its usefulness. PLEASE DO NOT CALL it directly from Sharepoint database as it is not recommended and supported by Microsoft. Just create this function in your own database and modify it as per your requirement.
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go
CREATE FUNCTION [dbo].[fn_HtmlEncode](
@Value nvarchar(1023),
@PreserveNewLine bit)
RETURNS nvarchar(4000)
AS
BEGIN
DECLARE @Result nvarchar(4000)
SELECT @Result = @Value
IF @Result IS NOT NULL AND LEN(@Result) > 0
BEGIN
SELECT @Result = REPLACE(@Result, N’&’, N’&’)
SELECT @Result = REPLACE(@Result, N’<’, N’<’)
SELECT @Result = REPLACE(@Result, N’>’, N’>’)
SELECT @Result = REPLACE(@Result, N””, N’'’)
SELECT @Result = REPLACE(@Result, N’”‘, N’"’)
IF @PreserveNewLine = 1
SELECT @Result = REPLACE(@Result, CHAR(10), CHAR(10) + N’<br>’)
END
RETURN @Result
END
SQL Server is an highly optimized and well tuned piece of code. It try to utilise Operating System resources as optimum as possible. Due to this, most DBA think that if they will increase RAM on the server then SQL Server will automatically start using it, right? Wrong, SQL Server can only use RAM more than 4GB if and only if,
- You are running Enterprise Editions of Windows 2003 Servers or Advanced/Datacenter version of Windows 2000
- You have enabled Operating System to use the extra RAM you have installed. Please check here for the details and how to do it.
- You are not running Express or Workgroup version of SQL Server. Please check here for further details about limitations in different versions of SQL Server
- you have enabled awe enabled option and set max server memory to the maximum memory you can allocate to SQL Server. This is applicatiable for 32 but versions of OS and not required in 64 bit version of Windows servers. Please check here for further details and how to configure the memoryfor SQL Server
Frequently I see the questions in newsgroups about a function to convert integer value to other bases like base 2 (binary), base 8 (octal) and base 16(hex). Following TSQL function, which was orginally mentioned by Itzik Ben-Gan in his book Inside Microsoft SQL Server 2005:TSQL Querying, provides you the ability to convert a given integer into any target base. I have just updated the function with more meaningful names and added some comments to clear the logic.
Here it is:
USE [AdventureWorks]
GO
IF EXISTS
(
SELECT * FROM sys.objects
WHERE object_id = OBJECT_ID(N‘[dbo].[fn_decToBase]‘)
AND type in (N‘FN’, N‘IF’, N‘TF’, N‘FS’, N‘FT’)
)
DROP FUNCTION [dbo].[fn_decToBase]
Go
Create function [dbo].[fn_decToBase]
(
@val as BigInt,
@base as int
)
returns varchar(63)
as
Begin
/* Check if we get the valid base */
If (@val<0) OR (@base < 2) OR (@base> 36) Return Null;
/* variable to hold final answer */
Declare @answer as varchar(63);
/* Following variable contains all
possible alpha numeric letters for any base
*/
Declare @alldigits as varchar(36);
Set @alldigits=‘0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ’
/* Set the initial value of
final answer as empty string
*/
Set @answer=”;
/* Loop until your source value is greater than 0 */
While @val>0
Begin
Set @answer=Substring(@alldigits,@val % @base + 1,1) + @answer;
Set @val = @val / @base;
End
/* Return the final answer */
return @answer;
End
Several times I have came across with the question that how can I search all columns of all tables in a SQL Server database for a particular value. Unfortunately, you can not perform this query directly by any already provided system table or object.
There are some fundamental points to remember:
- You have to iterate the list of tables and for each table you have to iterate each column and perform an exist query against it.
- You will need three types of queries due to the data types i.e. string, number and date and time.
I have found an excellent article
here which provides a good explanation along with the necessary sql script. I would recommend every reader to read this article.
As a DBA or even as a SQL Server Programmer, you may need a quick script to find relationship between tables. I found a useful script to do that in a SQL Server newsgroup. With some minor update, here is the script which lists the name of the parent table, child table, Referred table, foreing key table and name of the foreign key constraint. I hope you will find it useful. All credit goes to original author.
Select
object_name(rkeyid) Parent_Table,
object_name(fkeyid) Child_Table,
object_name(constid) FKey_Name,
c1.name FKey_Col,
c2.name Ref_KeyCol
From
sys.sysforeignkeys s
Inner join sys.syscolumns c1
on ( s.fkeyid = c1.id And s.fkey = c1.colid )
Inner join syscolumns c2
on ( s.rkeyid = c2.id And s.rkey = c2.colid )
Order by Parent_Table,Child_Table
If you want to check the name of the files and their respective sizes for the given database then following are two quick tsql scripts:
1. Use sp_helpfile
This stored procedure returns the file information for the selected database e.g.
USE AdventureWorks;
GO
EXEC sp_helpfile;
GO
It will return the resultset similar to following

By default, this view returns a column called size but this is actually the size in 8KB pages therefore, to get the exact size in KB, as returned by sp_helpfile, multiply it by 8 as mentioned in above query.
Microsoft has released the third service pack for SQL Server 2005. You can download it from here.
As many of us are still using SQL Server 2005 and has not moved to SQL Server 2008 yet therefore, I felt necessary to give you a breif overview of what has been offered in third service pack for SQL Server 200. Following is an outline:
- SP3 contains all hotfixes for SP2 along with some new features.
- If you are not ready to implement the SP3 yet then you can apply Cummulative update 11 for SQL Sever 2005 Service Pack 2 available here
- DBCC commands will display all error messages in SP3 in contrast to SP2 where you are only able to see first 200 messages if you do not specify ALL_ERRORMSGS option. In SP3 ALL_ERRORMSGS option does not have any meaning.
- Notification services (which has been discontinued in SQL Server 2008) of SQL Server 2005 will work with both SQL Server 2005 and SQL Server 2008 database engine after applying SP3
- There is a small update in Replication area i.e. a stored procedure sp_showpendingchanges now has one additional parameter @show_rows. This is a flag which allows you to specify two additional columns in the resultset for more detailed information. Further information is available here
- There are three updates in Reporting Services area:
- Report models can be created for Terra data databases. Further information is available here
- PDF rendering extension can now embed the font to display the document correctly on a computer where document fonts are not already installed. Further information is available here
- Sharepoint integrated mode has been optimized by reducing the number of calls to Sharepoint object model. Reports will render faster now.
I hope this overview will give you a brief idea about what is new in SP3.
Happy New Year to all readers and best wishes for 2009.