sql

Queries and functions which accept alias as parameter

Tagged:

The functions such as DELETED(), RECNO(), etc., which accept an optional workarea alias, could yield unexpected results when used in queries incorrectly.

Week number in a Month

Tagged:

Mline UDF - Return specific line

Tagged:

The ufn_Mlines() UDF for SQL Server is similar to the VFP Mline() function but w/o third parameter.
It's more an example than finished UDF. I didn't do much testing on it.

IsNumericEx UDF - Data type aware

Tagged:

The built-in SQL Server ISNUMERIC() function determines if character expression can be converted to one of the numeric types. The ufn_IsNumericEx() function accepts the second parameter - the data type to convert to and checks also for characters illegal for that data type. It doesn't check if the numeric value is in the range for specified data type though.

How does SQL Server Management Studio move columns?

Tagged:

SSMS (SQL Server Management Studio) does not use any kind of wizardry as one might think. It creates a new table, moves the data, drops the original table and renames the new table to the original name.

The design tool in SSMS can generate a script for any changes you have made.
This option is available via "Generate Change Script" in the "Table Designer" menu or via right-clicking the table editor.

View log usage in SQL2005 using Dynamic Management objects

Tagged:

SQL Server 2005 introduces a number of Dynamic Management objects. One of these is dm_os_performance_counters which gives you access to SQL Server Performance Counters that were only available through Performance Monitor. Several of the counters are related to the log so we can see the log usage for databases from within SQL Server.

Proper UDF - Capitalize String as Proper Names

Tagged:

The ufn_Proper() UDF for SQL Server is similar to the VFP Proper() function. It additionally allows to specify a set of delimiters.

Strextract UDF - Retrieves String Between Two Delimiters

Tagged:

The ufn_StrExtract() UDF for SQL Server is similar to the VFP StrExtract() function.