середа, 16 вересня 2009 р.

How to add 1 day to the date

MySQL : dateadd(dd, 1, getdate())
Oracle : SYSTIMESTAMP+NUMTODSINTERVAL(1,'day')
DB2 : CURRENT TIMESTAMP+1 DAY
PostgreSQL : LOCALTIMESTAMP+INTERVAL '1 day'

вівторок, 15 вересня 2009 р.

BCP and problems with Unicode

If you try loading the unicode file into mssql table that's what happens:

> bcp madhu1.dbo.testunicode in "D:\testunicode.txt" -S ABCSqlSrv -U sa -P sa -f "d:\fmt.txt"


Starting copy...
SQLState = HY000, NativeError = 0
Error = [Microsoft][SQL Native Client]Unexpected EOF encountered in BCP data-file

0 rows copied.
Network packet size (bytes): 4096
Clock Time (ms.) Total : 1

=================================

contents of testunicode.txt are :


मधुकर|pune|33
राहुल|pune|36

==========================

contents of format file fmt.txt are

8.0
3
1 SQLNCHAR 0 0 "|" 1 name SQL_Latin1_General_CP1_CI_AS
2 SQLNCHAR 0 0 "|" 2 address SQL_Latin1_General_CP1_CI_AS
3 SQLNCHAR 0 0 "\r\n" 3 age SQL_Latin1_General_CP1_CI_AS


================

However, this can be avoided by using -w option and removing -f option

Sphinx example for PHP

Here is a great example for Sphinx written in PHP : http://www.sphinxsearch.com/wiki/doku.php?id=php_example_script

Have fun.

Resetting forgotten root password

if you forgot the root password - here is the recipe to reset it:

1) kill mysqld
2) run

mysqld_safe –skip-grant-tables &

mysql -u root mysql

mysql> UPDATE user SET Password=PASSWORD(’newrootpassword’) WHERE User=’root’;
mysql> FLUSH PRIVILEGES;

3) kill the started MySQL server
4) restart it

Resetting forgotten root password

if you forgot the root password - here is the recipe to reset it:

1) kill mysqld
2) run

mysqld_safe –skip-grant-tables &

mysql -u root mysql

mysql> UPDATE user SET Password=PASSWORD(’newrootpassword’) WHERE User=’root’;
mysql> FLUSH PRIVILEGES;

3) kill the started MySQL server
4) restart it

понеділок, 14 вересня 2009 р.

Example of MSSQL quiet installation

It installs only MSSQL engine. Other possible features can be: SSMS, ADV_SSMS, BOL...

Setup.exe /QUIET
/INDICATEPROGRESS
/Action=Install
/FEATURES=SQLENGINE
/INSTANCENAME="EVAL33"
/SQLSYSADMINACCOUNTS="BUILTIN\Administrators"
/SECURITYMODE=SQL /TCPENABLED="1"
/NPENABLED="1"
/ADDCURRENTUSERASSQLADMIN="True"
/SQLSVCSTARTUPTYPE="Automatic"
/SQLSVCACCOUNT="NT AUTHORITY\LOCAL SERVICE"
/SAPWD="xxxxx"