Aug 8, 2010

ASP.Net Fundamentals

Jul 2, 2010

SQL Server cursor example

DECLARE db_cursor CURSOR FOR
SELECT name
FROM table
WHERE --some condition--

OPEN db_cursor 
FETCH NEXT FROM db_cursor INTO @name 

WHILE @@FETCH_STATUS = 0 
BEGIN 

--sql query using @name goes here--
FETCH NEXT FROM db_cursor INTO @name 
END 

CLOSE db_cursor 
DEALLOCATE db_cursor

SQL server query to drop default constraint and a column

declare @default sysname, @sql nvarchar(max)

select @default = name
from sys.default_constraints
where parent_object_id = object_id('MYTABLENAME')
AND type = 'D'
AND parent_column_id = (
select column_id
from sys.columns
where object_id = object_id('MYTABLENAME')
and name = 'MYCOLUMNNAME'
)

set @sql = N'alter table MYTABLENAME drop constraint ' + @default
exec sp_executesql @sql

alter table MYTABLENAME drop MYCOLUMNNAME

go

Jun 2, 2010

Easy shortcut to clear RAM in XP


You may know that Windows XP is not the best operating system in memory management. Many times you need to reboot your pc, just to clean the memory. Of course there is a simpler way to do this by creating a shortcut. Here is what you have to do:
  1. Right click on desktop, New -> Shortcut
  2. Copy/paste this piece of code in the location box:%windir%\system32\rundll32.exe advapi32.dll,ProcessIdleTasks
  3. Save the file
  4. You are done! Now every time you need some memory double click on your newly created shortcut