RAISERROR('YOUR TEXT GOES IN HERE', 0,
1) WITH NOWAIT;
2013-07-10
2013-07-08
TSQL - Error catching basic structure (try/catch/rollback)
begin try
begin tran
-- YOUR STATEMENTS HERE
commit tran
end try
begin catch
-- Display error
/*
SELECT
ERROR_NUMBER()
AS ErrorNumber,
ERROR_MESSAGE() AS ErrorMessage
;
*/
print('ERROR...');
print( 'Number: ' + cast(ERROR_NUMBER() as varchar(50)) );
print( 'Message: ' + cast(ERROR_MESSAGE() as varchar(max)));
-- Announce rollback
print('Rolling back!');
rollback tran
end catch
TSQL - If object exists (table for example)
if OBJECT_ID('DATABASE_NAME_HERE.SCHEMA_NAME_HERE.TABLE_NAME_HERE', 'U') is not null
begin
print('The table exists!');
end;
2013-07-05
PHP - UTF-8 fields into arrays
After this, you can use the array properly as it will store the UTF-8 characters appropriately (won't display nulls as it would otherwise). Json_encode will work just fine after this.
while( $row = mysql_fetch_assoc($result,MYSQL_ASSOC) ) {
$rows[] = array_map( 'utf8_encode', $row );
}
Subscribe to:
Posts (Atom)