Chris I really appreciate your help but you have lost me a little.
I have run the script you have kindly supplied and can see it has created something under the database under Programmabilty - Functions - Table-valued Functions.
What is this and how do i incorporate it into my current date database.
Sorry I know i'm thick.