Sunday, August 19, 2007

[muse] Grass is Greener ...

The priest from Marie and Renzo's wedding said:

It isn't that grass is greener on the otherside --- Grass is greener where it's watered.

Love it.

Thursday, August 16, 2007

[sql] Detecting / Filtering All Caps Text

Needed to detect if a field contained all caps / uppercase text. Once again, Yodakawa comes to the rescue.

-- Retrieve rows where FooText is not all caps
--(using it in where clause)
select top 100 FooText, * from FooTable
where FooText like '%[abcdefghijklmnopqrstuvwxyz]%'
COLLATE SQL_Latin1_General_CP1_CS_AS

-- Syntax for using it in the select
select top 100
isnull((case when FooText like '%[abcdefghijklmnopqrstuvwxyz]%'
COLLATE SQL_Latin1_General_CP1_CS_AS
then description2 else '' end), '')
from FooTable

[sql] Remove carriage return

SET FooText = REPLACE(FooText, CHAR(13), '')

Monday, August 13, 2007

[sql] Change object ownership

Changing object ownership in Micrsoft SQL Server

EXEC sp_changeobjectowner 'userfoo.tablefoo', 'dbo'

Saturday, August 11, 2007

[sql] Update table with column from another table

For example, if you have a list of students of all ages attending attending a field trip (Table "FieldTripList"), and you want to record who their current teacher is in the student information table (Table "Student")
update FieldTripList 
set FieldTripTeacher = s.CurrentTeacher
from Student s
where fk_StudentID = s.StudentID

More generic example with joining away to two tables: update columns in [TableA], by joining to [TableB] and [TableC] and using the values from those tables
update [TableA]
set TableAValueB = TableBValue,
TableAValueC = TableCValue
from [TableB], [TableC]
where TableAID = TableBID
and TableBID = TableCID

Wednesday, August 01, 2007

[muse] Jose and the hula hoop

The first time we tried to get Jose to just walk through a hula hoop, he was deathly afraid. We held out his favorite treat on the other side, and he would reach and reach for it with his neck, but his little feet stubbornly planted on the edge of the hoop.

Finally we held his foot up and gently nudged him through the hoop to get his treat. Suddenly he realized that the hoop wasn't going to eat him alive -- Jumping through hoop wasn't so hard after that!

What are things on my to-do and i-really-should list that are hula hoops -- really hard to get through the first time, because I don't know how easy it really is?