Feb
13
2008
0

Extract date from getdate(): the easier version

select convert(varchar(10), getdate(), 101)

You’ll get mm/dd/yyyy

Learn more from http://msdn2.microsoft.com/en-us/library/ms187928.aspx

Written by hkai in: SQL Server 2005 |
Jan
28
2008
0

Select a raondom row

Select a random row with mysql:

select column_name from table_name order by rand() limit 1

Select a random row with SQL Server

select top 1 column_name from table_name order by newid()

Written by hkai in: MySQL, SQL Server 2005 |
Jul
18
2007
2

Extract date from getdate()

the getdate() function will return a datetime value, but sometime you only need the DATE, without the time.

here’s the function that extract the date:

SELECT convert(datetime, floor(convert(float, getdate())))

Written by hkai in: SQL Server 2005 |
Jun
26
2007
0

mssql extension installation on Vista

I installed php 5.2.3 onto c:\php, but the script won’t connect to SQL 2005 through mssql extension.
The solution:
1. get the latest ntwdblib.dll from a machine which installed sql server 2000
2. put the dll to c:\php

The dll shipped with php 5.2.3 is version 7.0, and the latest is 8.0, which make the difference when connecting to a SQL 2005.

Written by hkai in: PHP, SQL Server 2005, Windows |
Feb
12
2007
0

transaction log is full

Sometimes the transaction log is full. here’s the commands to clean it.
BACKUP LOG db_name WITH TRUNCATE_ONLY
Change “db_name” to your account userID.
To verify the percentage of SQL transaction log space being used, run the following command from the same location:

DBCC SQLPERF(LOGSPACE)

Written by hkai in: SQL Server 2005 |

Powered by WordPress | Aeros Theme | TheBuckmaker.com WordPress Themes