Bulk Updates in T-SQL without Cursors

January 26, 2008 22:09 by bruce
I recently posted this on my personal blog, however it's quite a useful tip so I thought I'd post it here too. Sometimes you may want to perform a mass update on a table based on the contents of another table. The first thing you may think of is using a cursor to scroll through Table A and update Table B line by line. This is extremely slow. However, there is another way.

The way to do it is to join the two tables together then perform a self-update. I'll called the first table "Product" and the second table "UpdatedProduct".

UPDATE Product
    SET Price = NewPrice
    FROM Product
INNER JOIN UpdatedProduct ON UpdatedProduct.ProductId = Product.ProductId
So what have I done there? Well the first two lines instruct the dbms to update the Product table, altering the price. The second two lines provide a join of the 2 tables we are using and an interim relation that the Update can use as it's source. A table of 250,000 records took 3 seconds to update with this method but over 30 minutes using a cursor so the benefits are huge.

Currently rated 3.5 by 2 people

  • Currently 3.5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Categories: SQL
Actions: E-mail | Permalink | Comments (0) | Comment RSSRSS comment feed

3D Secure - What the deuce?

January 8, 2008 20:23 by bruce

If you engage in any kind of e-commerce then chances are you'll soon encounter the term "3D Secure". This is a security system introduced by Visa and Mastercard to protect against internet fraud. Yawn, pretty dull right. Well it is but it has a couple of real benefits for both e-commerce customers and e-commerce website owners. The most important of which is liability shift. This means that you, yes you Mr Website Owner, are protected against most fraudulent transactions. Given that recent reports state that Internet card fraud is rising at a rapid rate, "3D Secure" seems a no-brainer for most e-commerce sites. 

Still awake?

Good, excellent, keep with me because good stuff is on the way. "3D Secure" comes in two forms: "Verified by Visa" and "Mastercard Secure Code". Great, it's like a repeat of the VHS vs BetaMax wars. Well, not quite. Lucky for us Visa and Mastercard appear to have tackled the problem together and implementing both schemes into a website can be done simulataneously. Frankly that's good news for developers like myself. What's not good news is that the process of getting "3D Secure" into an existing site can be a little jarring and may require substantial changes to your payment gateway. The essence of the changes is the receipt of a ParEq code from your internet payment provider which needs to be sent to the card holders bank but more about that in a later article.

But is this optional?

Yes and no. Visa and Mastercard are strongly pushing the scheme and it's expected to become mandatory at some point in the near future. However most internet payment providers have already made "Mastercard Secure Code" mandatory for the acceptance of the UK Maestro cards. This means that if you want to accept the Maestro card, and you really do, then you will need to implement the "3D Secure" scheme on your site to do so. Existing sites that accept Maestro but do not accept "3D Secure" will soon cease to function. Fear not as in my next post I'll explain how to modify an existing .NET based payment gateway to accept "3D Secure" payments. You'll need your techy hat on and, in true Blue Peter style, a toilet roll and sticky-backed tape. Stay tuned.

 


Currently rated 4.2 by 5 people

  • Currently 4.2/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Astute Media Talk At Online Marketing Seminar

November 30, 2007 13:15 by simon

  

Astute Media stood head and shoulders above the competition at the recent Online Marketing Seminar run by the West Midlands ICT Hub.

Carl delivered an informative and straight talking presentation on how to maximise the potential of your business through Search Engine Optimisation of your website. The seminar lived up to its billing as a truly unmissable event, with Carl delivering a host of real world advice and information.

With delegates hurriedly scribbling down his every word I am confident that we demonstrated our knowledge and capabilities in this area of online marketing.

If you were unfortunate and missed Carl’s presentation, don’t panic as you can download it Here.

I am looking forward to the next time we get to present.


Currently rated 1.0 by 1 people

  • Currently 1/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

NO Hook, NO GO

November 30, 2007 13:06 by simon

At a recent networking event I was talking to someone who was trying to sell me into the idea of a purely advertising based website with no other content.

I questioned them on whether they were keen to be operating as a market place or as a site displaying clever and effective advertising, similar to an art gallery of adverts. The answer was a categorical NO.

They were at pains to point out that they had sunk a vast amount of investment into the site and also had two financial backers, so it must be a great idea! I then quizzed them on their success to date, as you may have guessed it was appallingly low. This lead me to question why this may be the case, the person in mind had no concept of the site needing a hook to attract an audience and in turn advertisers.

This is a worrying trend I have noticed more often where individuals are throwing money into on line businesses without understanding the market place and their offering. I don’t for one second believe we are looking at another DOT COM bubble burst, as these are all small start ups and I hope the financial institutions have learned their lesson from the last time round.

I do hope that individuals looking to take their business on line fully understand their offering within what is a very competitive and savvy marketplace.

 


Currently rated 2.5 by 2 people

  • Currently 2.5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

LINQ to SQL vs LINQ to Entities

October 21, 2007 19:08 by steve

With Microsoft .NET 3.5 on the horizon a lot of hype has been around Microsoft’s new Language Integrated Query (LINQ).  So what is LINQ?  LINQ is a set of extensions to the .NET Framework that provides the facility to query in-memory and external data.  When Visual Studio 2008 ships later this year, LINQ will support query in-memory objects (LINQ), XML (XLINQ), ADO.NET DataSets (LINQ to DataSet) and SQL Server (LINQ to SQL).

Next year, probably Q2 2008, Microsoft will release the ADO.NET Entity Framework.  The Framework will fully support LINQ through LINQ to Entities.  LINQ to SQL and the ADO.NET Entity Framework are both an O/RM (Object Relational Mapper) that enables you to map entities to your data source. 

So when should you use one over the other?  Well, if you’re using anything that isn’t SQL Server for your data store then the ADO.NET Entity Framework is your only option as LINQ to SQL only works with SQL Server.  If you are using SQL Server though, you still have the choice between the two technologies.  In simple terms, the ADO.NET Entity Framework is the big brother of LINQ to SQL and if your application requires one or more of the following then you should choose the ADO.NET Entity Framework:

  • Mapping a single class to multiple tables
  • Mapping to inheritance
  • Mapping directly many-to-many relationships
  • Mapping to a query
  • Querying a database that isn’t SQL Server
  • The ability to share the data model across other services such as Reporting Services, Integration Services etc.

The above lists just a few major differences between the two technologies. 


Scott Guthrie has a great overview of LINQ to SQL on his blog.


Currently rated 2.5 by 2 people

  • Currently 2.5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Will Google Penalise You for Hidden Text?

October 12, 2007 15:51 by carl

Looks like Google have finally clarified the issue with hidden text on your website and whether your site will be penalised for it.

Like most of Google's ideology, as long as it benefits users and is not an attempt to fool search egines then it is okay to hide text using CSS techniques.

An example of this could be using the display:none element to hide answers in a FAQ list

SEO Roundtable has more info on this and other search engine optimisation advice - we regularly visit the site for SEO news and views.


Currently rated 4.0 by 1 people

  • Currently 4/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Categories: Web Design | SEO | Google
Actions: E-mail | Permalink | Comments (1) | Comment RSSRSS comment feed

Pepsi Tattoo Viral Marketing Campaign

October 11, 2007 01:39 by carl

Check out this great viral marketing campaign from Pepsi for Pepsi Max.

A customised Flash video is generated from the information you provide about a friend taken from a limited list of dropdown choices.

Definitely targeted at the young male market (which pretty much counts me out!!) Pepsi have a young woman creating a video blog about the mystery date she met last night describing him in a fairly humorous way to you the viewer. The best bit, though, is that you can upload a piccy of your mate that is superimposed onto the young woman's mobile.

This all gets emailed to the friend in question and if you are a guy you would be hard pushed not to be tempted to do the same to another mate - the perfect viral campaign. 


Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Facebook to challenge MySpace's Music Platform

October 8, 2007 13:36 by steve
Facebook is developing a platform to rival MySpace.  Aimed towards musicians, bands and record labels to create pages and allow various widgets and gadgets to be embedded for music promotion.  An iTunes widget will be available which will eventually allow users to buy through the Apple.  The platform should be available by the end of the year.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

New Windows Live QuickApp

October 6, 2007 14:45 by steve

In associaion with ShapLogic the Windows Live Platform Group have released another QuickApp.  Based around the sample database of SQL Server 2005, Adventure Works, the website utilises a number of Live services to quickly build a fully functional web application.

What is in it from Windows Live?

  • Live ID being associated with ASP.NET Profiles
  • User Generated Video Content
  • Accepting file uploads
  • dropping the uploads onto a MSMQ Queue
  • automatically encoding using Expression Encoder
  • programmatically uploading to Silverlight Streaming
  • rendering the videos back from Silverlight Streaming
  • Map Point Web Service
  • Contacts Control
  • Spaces Photo Control
  • Windows Live Alerts

The app also makes use of SilverLight.

 You can view the test website or download the source from codeplex.


Currently rated 1.0 by 1 people

  • Currently 1/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Mixed Opinions @ MixUK 07

September 30, 2007 20:52 by steve

When the team went to this year’s MixUK 07 we witnessed a number of impressive demos.  The sneak peeks session at the end of the event was probably the most interesting and covered a variety of innovative ideas.  SeaDragon was an incarnation of the Microsoft acquisition of the company of the same name back in February 07.  This technology was shown earlier in the year at TEDMicrosoft is planning to ship SeaDragon next year as part of the Silverlight 1.1 release.

Something that interested Bruce was the talk on Transactional Memory and was presented by Simon Peyton Jones from Microsoft Research in Cambridge.  In a nutshell, Microsoft are trying to address the problems that arise with the performance overhead of managing concurrency in memory in a multi-core environment. 

On the first night Zi organised food and drink after the event.  I sat on the same table as Mike Ormond, Danny Thorpe and a few guys and gals from screenedit.  Thanks for a good night.


Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5