Friday, January 18, 2008

Generate INSERT statements from SQL Server table data

It is often necessary to copy data between two tables (for example between staging and production databases). SQL Server makes this task rather complicated (you have to resort to export/import). In MySQL it is possible to generate INSERT statements for all the records in a table, and some SQL Server client tools (such as the somewhat immature but excellent Toad) also do this.

The really low cost solution though is to use this stored procedure:
http://vyaskn.tripod.com/code.htm#inserts

Wednesday, July 25, 2007

SQL Server: Executing Jobs Synchronously

SQL Server jobs can be started from T-SQL using msdb.dbo.sp_start_job:

EXEC msdb.dbo.sp_start_job @job_name = 'My job name'

This call however will return immediately (i.e. the job executes asynchronously). Sometimes it is desirable for the job to be executed synchronously.  The following procedure accomplishes this.

Usage

Parameters:

  • @jobID UNIQUEIDENTIFIER (optional, only required if @jobName is not provided)
  • @jobName NVARCHAR(500) (optional, only required if @jobID is not provided)
  • @timeoutSeconds INT (optional, default 60 seconds)

Remarks:

  • The procedure will throw an error if the timeout period is reached before the job completes
  • The procedure will throw an error if the job fails

Examples:

EXEC common.dbo.execute_job_synchronously '2696980E-1E38-43C4-8350-29DBFC56974D', null, 30

EXEC common.dbo.execute_job_synchronously null, ‘My cool job’

EXEC common.dbo.execute_job_synchronously null, ‘My cool job’, 3600

Thursday, July 05, 2007

PONG

Tuesday, June 26, 2007

Surface Computing

Cool Phone Hacks

I came across these neat services (free during beta testing) on http://4hourworkweek.com.
 
http://jott.com  uses voice recognition to transcribe your spoken message into an SMS or email. The way they put it, "send SMS with your voice." Great for emailing yourself reminders, too.
 
http://pinger.com  lets you send voicemail to people without calling them. Perfect for late night messages or when you don't really want to talk to the recipient... (Next courtship ritual: breaking up on pinger.) Also great for messaging multiple people at once. Think of it as voice email.
 
http://grandcentral.com is your personal assistant that screens and routes calls and much, much more. My favorite feature: designating certain callers as SPAM. Future calls from those numbers automatically get a "number not in service" message when they call you. Genius.
 
 

The Visit

I thought this was really cool--a sign of things to come in our society. Crowd-financed movies... (Maybe there's hope for humanity after all.) I look forward to the day when blockbusters are financed with lunch money by kids who vote on what happens to Spidey in the next installment. (There's no hope for humanity.)
 

Saturday, June 23, 2007

The web is officially getting scary

Can you guess guess how much information about YOU is scattered on the web?
 

Friday, June 08, 2007

Determining the next identity value for a table

SELECT IDENT_CURRENT('Table1') + IDENT_INCR('Table1')

Also:

DBCC CHECKIDENT ('table_name', NORESEED)

To reseed the identity value:

DBCC CHECKIDENT ('table_name', RESEED, 10000)

Saturday, September 09, 2006

Windows Vista Gets Flak

http://money.cnn.com/2006/09/07/technology/Reality_check_Vista.biz2/index.htm?cnn=yes

I do agree with one thing in this article: XP SP2 is a fine OS. The reality is that soon enough, as more applications move online, what operating system you are running will be largely irrelevant. It's all in the browser.

Did I mention I loved Gmail? And Google Calendar? And Google Spreadsheets? Once Google Word comes online I'll probably find it convenient to ditch my current Outlook / Office combination. Hm, maybe not. I think I'll instead wait for Microsoft Office Online. Uh... Microsoft Office Live.

Oops... Did I give away a few trade secrets?.