Re: help neeed statement

From: J O Holloway (respond.to.group_at_your.convenience)
Date: 06/17/04


Date: Thu, 17 Jun 2004 15:39:54 -0500

Needs this setting ..

set concat_null_yields_null off

"Ilya Margolin" <ilya@unapen.com> wrote in message
news:O6TkrnKVEHA.584@TK2MSFTNGP09.phx.gbl...
> Darren,
>
> ...assuming they all have the same table definitions and the statement
> length would not exceed 8000 characters:
>
> declare @Stmt varchar(8000)
>
> select @Stmt = @Stmt + ' union all select * from ' + name
> from sysobjects
> where name like '%Mail%'
> and type = 'U'
>
> set @Stmt = right(@Stmt, len(@Stmt) - 11)
>
> exec(@Stmt)
>
> Ilya
>
> "Darren Spooner" <DarrenS@ihatespam.spacecamp.com> wrote in message
> news:OgJCoVKVEHA.2544@TK2MSFTNGP10.phx.gbl...
> > i need to create a union select statement with all tables that have
'Mail'
> > in the name of the table.
> > i will have an unknow number of tables (Mail, Mail1, Mail2, Mail3,
.....)
> > how would i creat the statement?
> >
> >
>
>



Relevant Pages

  • Re: help neeed statement
    ... One way to do it, and I'm not saying this is the best, is to use something ... from sysobjects ... union all ... > how would i creat the statement? ...
    (microsoft.public.sqlserver.programming)
  • Re: help neeed statement
    ... length would not exceed 8000 characters: ... from sysobjects ... > i need to create a union select statement with all tables that have 'Mail' ... > how would i creat the statement? ...
    (microsoft.public.sqlserver.programming)