Emil’s Blog

Programming Windows, .Net, EPiServer and whatnot…

[Powered by WordPress.]

January 31, 2006

Formatting dates in SQL

by @ 12:36. Filed under SQL Server

Here's an easy way of extracting ISO dates from a datetime column:

SELECT top 10
convert(varchar(10),starttid, 120) AS datum
-- style = 120 results in yyyy-mm-dd
FROM pass

Result:

2005-08-02
2005-08-04

January 25, 2006

UPDATE with ambigous table name

by @ 13:06. Filed under SQL Server

When doing an UPDATE and there are two occurrances of the table to update, then use the alias as table name. Example

UPDATE alias1       -- NOT the table name!
SET foo = 'bar'
FROM table_foobar alias1
INNER JOIN table_foobar alias2 ON alias2.foo = alias1.bar

January 10, 2006

Initializing arrays

by @ 13:09. Filed under .Net programming

Here's a handy way of creating an array and pass it as a parameter for a function call:

MyFunc(new Kommentar[] {kom1, kom2} );

No need for clumsy temporary variables etc. Neat, isn't it?

Here's another variation:

VeckoFacit[] facitarr;
facitarr = new VeckoFacit[]
{
    new VeckoFacit(...),
    new VeckoFacit(...),
    new VeckoFacit(...)
};

Initializing a multidimensional array:

int[,] intArray = new int[3, 2] { {1, 2}, {3, 4}, {5, 6} };
int[,] intArray = new int[,] { {1, 2}, {3, 4}, {5, 6} };

[powered by WordPress.]

jour·nal n. A personal record of occurrences, experiences, and reflections kept on a regular basis; a diary.

Internal links:

Categories:

Search blog:

Archives:

January 2006
M T W T F S S
« Dec   Feb »
 1
2345678
9101112131415
16171819202122
23242526272829
3031  


View Emil Åström's profile on LinkedIn

General links:

I read:

Visitors

Recent Comments

Spam caught

Other:

Clicky Web Analytics

36 queries. 0.557 seconds