• Looking at your problem a little bit you seem to not know how to properly reference other tables. You seem to routinely reference data so that is ends up being repeated. Also you should not use the text datatype, it is deprecated. http://msdn.microsoft.com/en-us/library/ms187993%28v=sql.90%29.aspx

    Here is a shot in the dark about a more normalized structure given what you posted.

    CREATE TABLE tblLocations

    (

    LocationID int identity not null,

    Location varchar(255) NOT NULL,

    Active bit NOT NULL CONSTRAINT DF_tblLocations_Active DEFAULT ((1)),

    CONSTRAINT PK_tblLocations PRIMARY KEY CLUSTERED

    (

    LocationID ASC

    )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]

    ) ON [PRIMARY]

    go

    CREATE TABLE tblContainerMovements(

    MovementID int NOT NULL,

    MovementDate datetime NOT NULL,

    MoveFromLocationID int NOT NULL,

    MoveToLocationID int NOT NULL,

    CustomerName varchar(64) NOT NULL, --This should be a FK to the CustomerID not their name

    ContractReference varchar(64) NOT NULL, --This should reference the Contract by the PK not a text description

    TNumber varchar(32) NOT NULL, --this appears to be poor RI again but not sure what it is.

    NotesAndComments varchar(max) NULL, --don't use text datatype, it is deprecated. instead use varchar(max)

    CONSTRAINT PK_tblContainerMovements PRIMARY KEY CLUSTERED

    (

    MovementID ASC

    )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]

    ) ON [PRIMARY]

    _______________________________________________________________

    Need help? Help us help you.

    Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.

    Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.

    Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
    Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
    Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
    Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/