Ok thanks got that now. I'm a bit new to stored procedures. I've set a string equal to my generated SQL statement, and then used Execute Immediate stringname; to run it, but it complains if the the sql statement/string is over 255 characters. Is there anyway I can execute a generated statement that is longer than 255 characters in the procedure ?