The requirement to work with postcodes, and specifically London postcode districts, has followed me around during my professional life. Below is a TSQL script to create a table for the postal districts in London. Enjoy!

CREATE TABLE london_postcodes (postcode VARCHAR(4) NOT NULL PRIMARY KEY CLUSTERED)
GO

SET NOCOUNT ON;
SET XACT_ABORT ON;
GO
BEGIN TRANSACTION;

INSERT INTO [dbo].[london_postcodes]([postcode])
SELECT N'E1' UNION ALL
SELECT N'E10' UNION ALL
SELECT N'E11' UNION ALL
SELECT N'E12' UNION ALL
SELECT N'E13' UNION ALL
SELECT N'E14' UNION ALL
SELECT N'E15' UNION ALL
SELECT N'E16' UNION ALL
SELECT N'E17' UNION ALL
SELECT N'E18' UNION ALL
SELECT N'E2' UNION ALL
SELECT N'E3' UNION ALL
SELECT N'E4' UNION ALL
SELECT N'E5' UNION ALL
SELECT N'E6' UNION ALL
SELECT N'E7' UNION ALL
SELECT N'E8' UNION ALL
SELECT N'E9' UNION ALL
SELECT N'EC1' UNION ALL
SELECT N'EC2' UNION ALL
SELECT N'EC3' UNION ALL
SELECT N'EC4' UNION ALL
SELECT N'N1' UNION ALL
SELECT N'N10' UNION ALL
SELECT N'N11' UNION ALL
SELECT N'N12' UNION ALL
SELECT N'N13' UNION ALL
SELECT N'N14' UNION ALL
SELECT N'N15' UNION ALL
SELECT N'N16' UNION ALL
SELECT N'N17' UNION ALL
SELECT N'N18' UNION ALL
SELECT N'N19' UNION ALL
SELECT N'N2' UNION ALL
SELECT N'N20' UNION ALL
SELECT N'N21' UNION ALL
SELECT N'N22' UNION ALL
SELECT N'N3' UNION ALL
SELECT N'N4' UNION ALL
SELECT N'N5' UNION ALL
SELECT N'N6' UNION ALL
SELECT N'N7' UNION ALL
SELECT N'N8' UNION ALL
SELECT N'N9' UNION ALL
SELECT N'NW1' UNION ALL
SELECT N'NW10' UNION ALL
SELECT N'NW11' UNION ALL
SELECT N'NW2' UNION ALL
SELECT N'NW3' UNION ALL
SELECT N'NW4'

COMMIT;
RAISERROR (N'[dbo].[london_postcodes]: Insert Batch: 1.....Done!', 10, 1) WITH NOWAIT;
GO

BEGIN TRANSACTION;

INSERT INTO [dbo].[london_postcodes]([postcode])
SELECT N'NW5' UNION ALL
SELECT N'NW6' UNION ALL
SELECT N'NW7' UNION ALL
SELECT N'NW8' UNION ALL
SELECT N'NW9' UNION ALL
SELECT N'SE1' UNION ALL
SELECT N'SE10' UNION ALL
SELECT N'SE11' UNION ALL
SELECT N'SE12' UNION ALL
SELECT N'SE13' UNION ALL
SELECT N'SE14' UNION ALL
SELECT N'SE15' UNION ALL
SELECT N'SE16' UNION ALL
SELECT N'SE17' UNION ALL
SELECT N'SE18' UNION ALL
SELECT N'SE19' UNION ALL
SELECT N'SE2' UNION ALL
SELECT N'SE20' UNION ALL
SELECT N'SE21' UNION ALL
SELECT N'SE22' UNION ALL
SELECT N'SE23' UNION ALL
SELECT N'SE24' UNION ALL
SELECT N'SE25' UNION ALL
SELECT N'SE26' UNION ALL
SELECT N'SE27' UNION ALL
SELECT N'SE28' UNION ALL
SELECT N'SE3' UNION ALL
SELECT N'SE4' UNION ALL
SELECT N'SE5' UNION ALL
SELECT N'SE6' UNION ALL
SELECT N'SE7' UNION ALL
SELECT N'SE8' UNION ALL
SELECT N'SE9' UNION ALL
SELECT N'SW1' UNION ALL
SELECT N'SW10' UNION ALL
SELECT N'SW11' UNION ALL
SELECT N'SW12' UNION ALL
SELECT N'SW13' UNION ALL
SELECT N'SW14' UNION ALL
SELECT N'SW15' UNION ALL
SELECT N'SW16' UNION ALL
SELECT N'SW17' UNION ALL
SELECT N'SW18' UNION ALL
SELECT N'SW19' UNION ALL
SELECT N'SW2' UNION ALL
SELECT N'SW20' UNION ALL
SELECT N'SW3' UNION ALL
SELECT N'SW4' UNION ALL
SELECT N'SW5' UNION ALL
SELECT N'SW6'

COMMIT;
RAISERROR (N'[dbo].[london_postcodes]: Insert Batch: 2.....Done!', 10, 1) WITH NOWAIT;
GO
BEGIN TRANSACTION;

INSERT INTO [dbo].[london_postcodes]([postcode])
SELECT N'SW7' UNION ALL
SELECT N'SW8' UNION ALL
SELECT N'SW9' UNION ALL
SELECT N'W1' UNION ALL
SELECT N'W10' UNION ALL
SELECT N'W11' UNION ALL
SELECT N'W12' UNION ALL
SELECT N'W13' UNION ALL
SELECT N'W14' UNION ALL
SELECT N'W2' UNION ALL
SELECT N'W3' UNION ALL
SELECT N'W4' UNION ALL
SELECT N'W5' UNION ALL
SELECT N'W6' UNION ALL
SELECT N'W7' UNION ALL
SELECT N'W8' UNION ALL
SELECT N'W9' UNION ALL
SELECT N'WC1' UNION ALL
SELECT N'WC2'

COMMIT;
RAISERROR (N'[dbo].[london_postcodes]: Insert Batch: 3.....Done!', 10, 1) WITH NOWAIT;
GO