Download the Community Technology Preview (CTP) of Microsoft SQL Server 2005 :

http://www.microsoft.com/downloads/details.aspx?familyid=6e4aac3a-9d85-4734-b1fd-318fb83b0d29&displaylang=en


Download a stand-alone copy of the documentation and tutorials for the Microsoft SQL Server 2005 Community Technology Preview (CTP) September 2005 :

http://www.microsoft.com/downloads/details.aspx?familyid=adc75e35-7245-4038-9b8a-b8fabaec16da&displaylang=en


To Truncate the log file:

Backup the database (I always prefer to backup first to be on the safer side ;)).

Detach the database, either by using EM or by executing :

Sp_detachDB [DBName]

Delete the transaction log file. (I prefer to rename the file, just in case if something goes wrong)

Then attach the database again using:
Sp_AttachDB [DBName]

When the database is attached, it creates a new transaction log file.

 

To shrink the log first backup the log using:

backup log [DBName] with no_log

 

Using Enterprise manager:

 

Right click on the database, All tasks, Shrink database, Files, Select log file, OK.

Using T-SQL:

dbcc shrinkfile ([log_name])


Here [log_name] is the logical name of the log file as found from sp_helpdb

with 0 Comments
once you connect to the sqlserver , the server details are maintained as a history and the next time you want to connect to the server you get a dropdown to select from the previously connected servers. Now if you want to delete this history, there is no GUI tool available for it. The trick to delete this history is to delete the registry entries: HKEY_CURRENT_USER\Software\Microsoft\Microsoft SQL Server\80\Tools\Client\PrefServers clear the entries from prefservers.. this should work. since it is a registry modification, do it on your own risk.
with 6 Comments

"Not Associated with a trusted SQL Server Connection" when I try to connect to an SQL database and use a valid SQL username?

This is a very common question I have come across.
This occurs typically when Microsoft Sql Server installation is configured to use only Windows authentication and not SQL Server authentication.
So when u try to login using sql server account this error occurs.

 To solve the problem: Change the Authentication change the authentication mode to sql server authentication.
1. Start SQL Server Enterprise Manager (Start, Programs, Microsoft SQL Server, Enterprise Manager).
2. Navigate to the SQL Server system in the Microsoft Management Console (MMC) treeview pane by selecting Console Root,     
    Microsoft SQL Servers, SQL Server Group, (or ); right-click the server; and select Properties from the context menu.
3. In the SQL Server Properties dialog box, select the Security tab.
4. In the Security section, make sure that Authentication is set to "SQL Server and Windows" and not "Windows only" .

what is better constraint or Trigger??
If it is a job of just referential integrity I would use a constraint, where as if more complex logic is to be performed, then trigger.
constraints are proactive - they prevent unwanted actions from happening.
Triggers are reactive - they rollback the damage.
While deleting a record from a table a constraint would tell not to delete a parent record if child records exist.
A trigger rolls back the delete operation if you try to delete a parent record having child records.
Constraints apply to underlying table.
Triggers can access multiple tables(even tables in other databases).
With a trigger you can generate more custom and understandable and user friendly error messages as compared to cryptic messages returned by the constraints.

These are a few points to compare.. more are welcome.

with 3 Comments

An Israeli hacker reveals: A security hole in Gmail allows the compromise of users' email boxes – without the need of a password.

Link

with 5 Comments

 All good programmers test their code. But can testing be easier? Can it be better? S. A. Miller shows how unit tests can help, along with an open source testing framework called TSQLUnit.

check the article here

with 3 Comments

Set ANIS_NULLS
For something like
select * from foo1 where a not in (select a from foo2)
If anis_nulls is ON and if the table foo2 is empty no records from foo1 are selected.
If this comparision statement exits inside a stored procedure then ANSI_NULLS setting should be done before the compilation of the stored procedure, if the set statement is inside the procedure, the ANSI_NULL setting is not affected.
From BOL:
For stored procedures, SQL Server uses the SET ANSI_NULLS setting value from the initial creation time of the stored procedure. Whenever the stored procedure is subsequently executed, the setting of SET ANSI_NULLS is restored to its originally used value and takes effect. When invoked inside a stored procedure, the setting of SET ANSI_NULLS is not changed.

I never knew this. so when today there was a bug in a stored procedure I tried to debug it, I was not able to find anything wrong with it, since the same script was working on my local machine, after drilling it down to NULL comparision
found the above thing. so recompiled the sp with set options at the start before the create statement which solved the problem.
Also remember: The setting of SET ANSI_NULLS is set at execute or run time and not at parse time.

with 8 Comments
have a read here
with 3 Comments

Google has launched the desktop search engine Google Desktop search beta yesterday.
Google says that it is a desktop search application that provides full text search over all the files.
Seems to be a cool app, but I do have a few doubts about it... like it tracks all the activity done on the machine right from the normal work done to the emails recieved it tracks all the websites visited and stuff..... so how secure is it anyway?
anyone who get access to my machine knows what I was been doing what sites I have browsed ... is that the case??
I have downloaded the installable but not yet installed it cause it says that after installing it, it needs to index all the files on the hard disk which might take hours... so planning to install it tonight while leaving ... lets see how it comes up.
you can download it here

know more about google desktop search beta

with 4 Comments

Is anyone aware how to calculate the occupied size of a row in a table?

 

with 5 Comments

It seems the Gmail invitations are back... I got a coupla them, if anyone is interested write me at harshalmistry@gmail.com

 

with 4 Comments

Recently I came across something called SQL Server Reporting Services Skills Assessment after diggin in found that MS offers of assessments on a range of MS products also the site says “By completing a Microsoft Skills Assessment, you will receive a Personalized Learning Plan to help you understand if you are ready to implement specific business solutions. Your Personalized Learning Plan will include the Microsoft Official Curriculum courses, Microsoft Press books, and Microsoft TechNet resources that will help you with your preparation.”

So give it a try here.

with 5 Comments

The wipro CEO Azim Premji wants the Techie taxed!!!
Read the whole story here .

with 6 Comments
  Yukon introduces a new isolation level called SNAPSHOT which allows you to work in a mode where writers do not block readers, providing readers with a committed version of the data they request. SQL Server Yukon maintains a linked list in tempdb that tracks changes to rows and constructs an older, committed version of data for readers. This isolation is useful for optimistic locking, where UPDATE conflicts are not common. If Process 1 retrieves data and later attempts to modify it, and if Process 2 has modified the same data between the retrieval and modification, then SQL Server produces an error upon Process 1's modification attempt because of the conflict. Then, Process 1 can try to reissue the transaction. This mode can be efficient in situations where update conflicts are not common.
  In order to allow working in a SNAPSHOT isolation level, you must turn on the database option ALLOW_SNAPSHOT_ISOLATION.
with 6 Comments

I have heard and read so much about Yukon now that I can't wait to get a peek of it...
so had a talk with the PM about using Yukon or having in touch with the latest softwares and stuff,
his reasoning though right, was using new softwares is a company decision blah blah blah...

So don't know when I'll be working on it,  but till that time comes I thought why not learn the new stuff and blog about it ;)

so watch this space.

 

Tara has posted some very useful database maintainance routines over a past couple of weeks

and she has summarized the whole of them here. 

I was going through this article on difference between select and set on vyas's website
here is an small extract of it which would be usefull:
When using a query to populate a variable, SET will fail with an error, if the query returns more than one value. But SELECT will assign one of the returned rows and mask the fact that the query returned more than one row. As a result, bugs in your code could go unnoticed with SELECT, and this type of bugs are hard to track down too. Here is an example:

/* Consider the following table with two rows */
SET NOCOUNT ON
CREATE TABLE #Test (i int, j varchar(10))
INSERT INTO #Test (i, j) VALUES (1, 'First Row')
INSERT INTO #Test (i, j) VALUES (1, 'Second Row')
GO

/* Following SELECT will return two rows, but the variable gets its value from one of those rows, without an error.
This may not be what you were expecting. Since no error is returned,
you will never know that two rows existed for the condition, WHERE i = 1 */
DECLARE @j varchar(10)
SELECT @j = j FROM #Test WHERE i = 1
SELECT @j
GO

/* If you rewrite the same query, but use SET instead, for variable initialization, you will see the following error */
DECLARE @j varchar(10)
SET @j = (SELECT j FROM #Test WHERE i = 1)
SELECT @j

Server: Msg 512, Level 16, State 1, Line -1074284106
Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.

---------
the whole article can be found here.

Many times I have read comments that its better to have a pointer to the image be saved in the database and the image be managed by the operating system.
Here is some insight about  the pros and cons of managing images in the database.
Here are some of the Pros for storing the images in the database as a better choice and the application in which the images will be used can count on the benefits of a database system.

The benefits of storing the images in the database include:

Scalability: Although file systems are designed to handle a large number of objects of varying sizes, file systems usually are not optimized for a huge number of small files.
Database systems are optimized for such cases.

Availability: SQL server has availability features that extend beyond those provided by the file system.

SQL Server replication is a set of solutions that allow you to copy, distribute and potentially modify data in a distributed environment.

Log Shipping provides a way of keeping a stand by copy of a database in case the primary system fails.

As far as the cons for it are concerned
Storing the image in the database increases the database size dramatically and obviously the overall performance of the database is degraded.

Any more insights are welcome.

you may find more detailed info on how to link to the images in sql server here

with 1 Comments

There are a few system functions for returning the number of connections but,they are many times misunderstood.


@@CONNECTIONS : Returns login attempts since the server was started.

@@MAX_CONNECTIONS: Returns maximum number of connections supported.

The simplest way to list all users and processes is to use the system stored procedure:  sp_who
To list all active users:  sp_who 'active'
to list details about a particular user:    sp_who 'login-name'
Now to obtain the current number of connections to the server, you can use:

SELECT COUNT(*) AS CONNECTIONS FROM master..sysprocesses

 And just to get the user connections, omitting the system processes, use:

SELECT cntr_value AS User_Connections FROM master..sysperfinfo as p
WHERE p.object_name = 'SQLServer:General Statistics' And p.counter_name = 'User Connections'

 

 


with 3 Comments