Alejandro Mesa
3/20/2007 3:41:00 PM
Sugandh Jain,
If the name of the table is passed as a parameter, then you will have to use
dynamic sql, and creating a temporary (local) table is not possible because
as soon as the dynamic batch has finished, the temporary table will be drop
automatically.
AMB
"Sugandh Jain" wrote:
> Hi,
> Yes, I read about this in the BOL. I think I will get my work done like
> this. One more question though.
> The table to which the insert is being done is known the stored procedure
> from a parameter sent from the front end.
> So, I want to make a temp table exactly similar to the one which is sent. It
> is sure that this table does not contain any identity column.
>
> So, now how to make a temp table with the same table structure as some other
> table in DataBase.
>
> Many Thanks,
> Sugandh
>
> "Alejandro Mesa" <AlejandroMesa@discussions.microsoft.com> wrote in message
> news:347B617D-90C5-4101-91C3-B4445BCA8EBC@microsoft.com...
> > Sugandh Jain,
> >
> > If you are using SQL Server 2005, you can take advantage of the new
> > "output"
> > clause of the "insert" statement, from where you have access to the
> > "inserted" table and can insert those rows into another table (variable,
> > temporary or permanent). See "insert" statement in BOL.
> >
> >
> > AMB
> >
> > "Sugandh Jain" wrote:
> >
> >> Hi,
> >> I want to avoid using a trigger and following is the situation I am in.
> >>
> >> I send a dynamic sql from front end to insert rows in a particular table.
> >> Now, with the inserts some other tables should be updated/inserted with
> >> values based on the new rows coming in.
> >>
> >> right now, i use the trigger and use the INSERTED table available in the
> >> trigger to get the inserted rows.
> >>
> >> How can i get these inserted rows in the stored procedure where the rows
> >> are
> >> inserted to the table.
> >>
> >> Many thanks,
> >> Sugandh
> >>
> >>
> >>
>
>
>