Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 how to save result of select statements with union

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2005-03-04 : 08:16:41
joey writes "hi ! aim writing a stored procedure written below can i as favor to any guru to help me out? . I want the result of this procedure to save in a table i used into table but it has an error. thanks in advance

CREATE PROCEDURE jgm1
AS
select inv_num_,custnm,custname,trans_code,brdate as dateall from dbo.invoice_brok
UNION
select inv_num_,custnum_,custnm,trans_code,date____ as dateall from dbo.invoice_dom
union
select inv_num_,custnum_,custnm,trans_code,date____ as dateall from dbo.invoice_int
union
select inv_num_,custnum_,custnm,trans_code,date____ as dateall from dbo.invoice_tr
order by dateall
GO"

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-03-04 : 09:01:47

try this
CREATE PROCEDURE jgm1
AS
Insert into TableName
(
select inv_num_,custnm,custname,trans_code,brdate as dateall from dbo.invoice_brok
UNION
select inv_num_,custnum_,custnm,trans_code,date____ as dateall from dbo.invoice_dom
union
select inv_num_,custnum_,custnm,trans_code,date____ as dateall from dbo.invoice_int
union
select inv_num_,custnum_,custnm,trans_code,date____ as dateall from dbo.invoice_tr
) T


Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -