Can anyone tell me how can I create a table in (SQL Server 2000) direct from a stored procedure execution or from a SELECT result?
I need something like this: CREATE TABLE < t > FROM <sp_name p1, p2, ...>or like this:
CREATE TABLE < t > FROM SELECT id, name FROM < w > ...
Thank you!
Look at SELECT ... INTO command.|||use northwind
select * into #tablex from employees
select * from #tablex
|||Sorry joeydj but your example create a copy of another table! I need to create a table that contains only a few columns from another table, so that why I need to use a SELECT or a stored procedure that build and execute a SELECT.
Can I do that?
Thanks!
|||Sorry gavrilenko_s but I miss your post! You are right! That is the solution! Thanks!|||hi,
first you have to create a table that has a similar
structure with the Sp
and then you can use
insert into temp
exec sp1
here's a sample snippet
USE NORTHWIND
select 'my name.........................12345' as productname, 10000.00000
as unitprice, 10000.0000 as quantiTY,
10000.0000 as discount, 10000.0000 as extendedprice
into tempxtruncate table tempx
insert into tempx
exec dbo.CustOrdersDetail '10248'select * from tempx
drop table tempx
also suggest you make use of UDFs
cheers :)
No comments:
Post a Comment