Friday, July 3, 2009
Check Leap Year in mysql
DROP FUNCTION IF EXISTS `isLeapYear` $$
CREATE DEFINER=`root`@`192.168.10.116` FUNCTION `isLeapYear`(_year varchar(10)) RETURNS varchar(10) CHARSET latin1
BEGIN
declare tt varchar(10);
set tt = if(((_year % 4 = 0) AND ( (_year% 100 != 0) OR (_year % 400 = 0)))=1,'true','false');
return tt;
END $$
DELIMITER ;
Thursday, May 28, 2009
Writing Registy Using VB.NET
'function for read registry values
Dim regKey As RegistryKey
Dim i As Boolean
Try
regKey = Registry.CurrentUser.OpenSubKey("Software\adsdf\asdf", True)
regKey.SetValue(reg_key, val)
regKey.Close()
i = True
Catch ex As Exception
i = False
regKey.Close()
End Try
Return i
End Function
This function is for writing windos regsitry using vb.net
Here reg_key is the registry key and val is value of that key
Tuesday, May 19, 2009
Export MySQL Data to Comma Seperated File
SELECT `doc_no`,`column1`,` column2`,` column3`
INTO OUTFILE 'C:\\result.txt'
FIELDS TERMINATED BY ','
OPTIONALLY ENCLOSED BY '"'
LINES TERMINATED BY '\n'
Here
`doc_no`,`column1`,` column2`,` column3` are the column name which you want to export
'C:\\result.txt' is the exported csv file name.
table_name is the table which you want export in to csv
imports comma seperated file (csv) to mysql database
below show the simple query you want
LOAD DATA LOCAL INFILE 'C:\\test.csv'
INTO TABLE testing
FIELDS TERMINATED BY ','
ENCLOSED BY '"' LINES
TERMINATED BY '\\n';
Here
C:\\test.csv is the csv file path that you want to import in to mysql database
testing is the table that imported data hold in
\\n is the line end char of the csv file this may change \\r\\n , etc ...
by default mysql allow to import less than 1MB file for import into mysql,but if you want large file imports into mysql then you should do some changes.This happen because it by default mysql has Max packet size = 1MB
using mysql-administrator GUI you can easily change this value
In mysql-administrator GUI --> startup varables --> Advanced Networking tab --> data/memory size group box --> Max packet size = "your_value"
http://dev.mysql.com/doc/refman/5.0/en/mysqlimport.html