Saturday, December 31, 2005
Most Important Infotech Stories of the year '2005
Also go thru this interesting article "Life after Silicon" about Nanotechnology which may replace silicon or any semiconductor technology from the chip making industry.
FOR Power
“FOR” command in Windows (not a T-SQL FOR statement) is a useful statement. I am using this command in almost all of my windows and SQL Server administrative script requirements. Here is the one use of FOR command in SQL Server environment.
I had a requirement to automatically load all SQL scripts from a particular folder into a SQL Server. For this requirement I preferred batch script, which use FOR command. We have scheduled a job in SQL Server with the batch file that loads SQL Scripts into the SQL Server.
You can find the batch file from the following link.
http://www.skchandra.com/batchfiles/load_scripts.zip
The batch file uses the Windows authentication method and loads all SQL scripts with .SQL extension from the folder where the batch file resides.
Set Vs Select
To assign a value to a variable we use either SELECT or SET statement based on our preference. Is there any difference between the two assignment statements? I can see few differences when using these two statements. They are:
- We can use SELECT statement when we assign values to more than one variable. However SET can be used to assign value to one variable at a time.
- SELECT statement works well with record sets, hence it won’t throw any error when we assign a record set value to a variable. Whereas SET statement throws an error if we try to assign record set value to a variable if the record set returns more than one value.
USE northwind
GO
DECLARE @selectVar varchar(40), @setVar varchar (40)
SELECT @selectVar = LastName FROM Employees
SELECT @selectVar
SET @setVar = (SELECT lastname FROM Employees WHERE EmployeeID = 1)
SELECT @setVar
In the above code, SELECT assignment statement accepts the record set and assigns the last value to the variable selectVar. However, if we use SET statement without limiting the result of the SELECT statement to a single value (by using where clause), then the SET statement returns an error. - SET statement is ANSI standard where SELECT is not.
Monday, December 12, 2005
Ready Launch Tour 2005 - II
Visit The Notorious Bill Gates for his view on Bangalored Jobs.