Thanks, I am going to go down the dynamic SQL route..
"xyb" wrote:
> On 3æ??21æ?¥, ä¸?å?10æ?¶04å??, NH <N...@discussions.microsoft.com> wrote:
> > I have a load of tables named RESULT1,RESULT2,RESULT3, etc.
> >
> > What I want to do is automatically load the contents of all of these tables
> > into one large table.
> >
> > The problem is that the number of columns varies dramatically..
> >
> > For example; RESULT1 may have 5 columns, RESULT2 may have 3 columns, and
> > RESULT3 may have 4 columns.. (all of which are integers)
> >
> > I have created a table called RESULTS with 4 columns
> >
> > When I try something along the lines of;
> >
> > INSERT INTO RESULTS
> > SELECT * FROM RESULTS1
> >
> > I get an error saying that the number of columns don't match..
> >
> > I thought that if the column names matched, then a mismatched number of
> > columns didn't matter, but I was obviously wrong...
> >
> > Is there a way round this that doesn't involve specifying each column? I
> > don't want to do this because the number of columns is constantly varying,
> > and can be as many as 255!
> >
> > Thanks
> >
> > NH
>
> first,how can you load all the data that some of them have the columns
> over 4 into a large table.
> second,if this make te sence,use dynamic sql with reference to sys
> objects table,you can google from pubs :)
>
>