Archives

Archives / 2005 / January
  • [wish] "CREATE TABLE ... LIKE" in SQL Server 2005

    My friend Dave recently told me about the "CREATE TABLE ... LIKE " SQL statement. MySql and DB2 both support it, and it's apparently part of the SQL99 spec. It's not supported by T-SQL (SQL Server).

    CREATE TABLE LIKE is quick way of cloning the structure of an existing table, including any indexes (but not foreign keys). This can be particularly useful in creating new tables to be added to an existing MERGE table.

    mysql> CREATE TABLE log_20041124 LIKE log_20041123;

    As far as I know, this will not be supported by T-SQL, despite all the other SQL enhancements in Yukon. You can copy everything except the keys / indexes with "SELECT INTO":
     
    select * into CustomersCopy from Customers where 1 = 0
     
    That copies the structure, but doesn't copy the indexes.

    One other trick I learned a bit ago: you can select a table in Enterprise Manager and hit control - c. Then go to notepad / query analyzer / etc. and paste to get the create table statement (with all the indexes and stuff). You can also right click a table in Query Analyzer and select "Script Object To New Window As..." to get a Create statement. Still, none of these offers quite what the CREATE TABLE ... LIKE statement does - script level copy of table scructure and indexes.

    Read more...

  • LogParser and WMI: separated at birth?

    LogParser: a cool tool that supports SQL-like queries against "text-based data such as log files, XML files and CSV files, as well as key data sources on the Windows┬« operating system such as the Event Log, the Registry, the file system, and Active Directory┬«." [via MSDN]

    Read more...

  • [tip] Use WinMerge for compare / merge in StarTeam

    We use StarTeam for source control at my work. I'm not a huge StarTeam fan, and I think the compare / merge portion is pretty much unusable. Fortunately, you can pick your own alternative merge and compare utilities. I like WinMerge . Here's how to set it up:

    1. Tools / Options / File tab.
    2. Check "Merge utility" and "Comparison utility" checkboxes.
    3. Browse to WinMergeU.exe
    4. Enter the following for merge utility options: /dl "StarTeam Version" /dr "Your Changes" $branchtip $usertip $resultfile
    5. Enter the following for comparison utility options: /dl "StarTeam or Older Version" /dr "Your Changes or Newer Version" $file1 $file2

    References:
    WinMerge command line info: http://winmerge.sourceforge.net/2.2/manual/commandline.html
    Araxis Merge integration info for various source control systems: http://www.araxis.com/merge/scm_integration.html

    powered by IMHO 1.2

    Read more...

  • [sql] T-SQL Quiz

    A user executes the following two queries in SQL Server Query Analyzer. Query 1 returns no rows; Query 2 returns one row. Why?

    Read more...

  • [OT] Horses and monkeys

    Yesterday evening I wanted to take a quick catnap after dinner. That's not too easy with a 1 year old and a 3 year old who want to play with Dada, but I can sometimes get away with it if I convince them we're playing.

    "I'm going to play 'nap on the couch' now. I'm the little baby and you can put me to sleep."

    "What will you dream about?" Rosemary, the three year old, asked.

    "Um... horsies and monkeys and that kind of stuff," I mumbled as I drifted off.

    I woke up about 10 minutes later. I learned to appreciate even tiny doses of sleep when I was in the military.

    Rosemary was standing a foot away from me, smiling. "Did your dreams come true?" she asked.

    "Um... I don't know... uh..." I was groggy. I rarely remember my dreams, and usually when I do they're utter nonsense. How to answer this one?

    "Wait a second, Dada." She scurried out of the room. I glanced around and noticed I was surrounded by a huge pile of stuffed horses - she'd obviously been gathering and arranging them the whole time I slept. When did we get so many stuffed horses? Rosemary returned with her only stuffed monkey, a tiny little sock monkey.

    "Did your dreams come true, Dada?" She asked again, expectantly.

    Yes, sweet little girl. My dreams have come true.

    Read more...

  • New Google tag... rel="nofollow"?

    Scoble mentioned this morning that Google would be announcing a new tag today, so I've been keeping my eyes peeled. Anne van Kesteren just blogged about it - it looks like it's rel="nofollow".

    Simon Willison seems to spell it out the best:

    Reading between the lines (which in this case isn't particularly hard), this and this (don't forget to view source) suggest that Google are soon to announce that they won't be calculating PageRank for links with a rel="nofollow" attribute. Finally, an official way of fighting the economics of comment spam by denying PageRank on user-submitted link content. Sam Ruby points to Mark Pilgrim's prediction that spammers won't care - they'll spam anyway, on the offchance that they hit somewhere undefended. I'm optimistic - if the major weblog (and wiki) vendors get behind this one it could help stem the tide.

    This is cool - it lets content link sources control the page rank boost they give to the link target - perfect for comment spam, forum spam, etc. Let's hope that Mark Pilgrim is wrong - if this really does make comment spam ineffective, maybe it will at least slow down a bit.

    powered by IMHO

    Read more...

  • [OT] Half-Life back story, mods

    I'm a fan of the Half-Life thing. I stink at it - unlike my little brother who finished it 4 days after it was released and is now literally lapping me, I'm still slogging through. I play for the love of the game, though, and because I really enjoy the storyline.

    Read more...

  • [wish] Community code namespace standards

    I'm happy to see the huge growth of community contributed code - things like RSS.NET, sharpziplib, ftp classes to tide us over 'til .NET 2.0, etc.

    One thing that bothers me about it is the namespaces. The .NET System namespaces are beautifully organized, but community / open source code namespaces are an anarchistic babel. Those that originate from a big company usually start with the company name, those that come from larger project usually take the the project's name.

    One-off code snips / hobbyist / micro-projects usually contain a random concatenation of some or all of the following words: monkey, alien, squishy, bug, fuzzy, code, util, works, MyNamespace, namespace, ware, example, contrib, and lib: monkeyCode, fuzzyAlienWare, utilLib, bugware, etc. This is the case I'm talking about.

    I can sort of see the point of company based or project based namespaces. I don't see any value in random namespace names, though. They don't tell anyone anything, and they look suspect to managers and system admins - "What's this bugworksLib.dll?"

    I understand there may be concern about twenty different Community.Network.Ftp namespaces floating around, but .NET is smart enough to figure it out, or at least warn you at compile time.

    I'd like to see a community standard best practice for community code namespaces - anything remotely professional would do: Community, Shared, Code, etc.

    Thoughts?

    powered by IMHO

    Read more...