Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Create Table 'As' In Oracle

Status
Not open for further replies.

vnk

IS-IT--Management
Nov 14, 2001
33
0
0
US
Hi All,

Is there any command equivalent to "Create table tablename as select * from table2" in SqlServer as in Oracle.

Thanks In Advance,
VNK.
 
To create a table structure and insert data from the old table use the following.

Select * Into NewTable
From OldTable

If you only want the structure do the following.

Select * Into NewTable
From OldTable
Where 1=2 -- always false so no rows will be selected Terry L. Broadbent - DBA
Computing Links:
faq183-874 contains "Suggestions for Getting Quick and Appropriate Answers" to your questions in the SQL Server forum. Many of the ideas apply to all forums.
 
Thanks A Lot for the input, but I ended up having a different problem. It complains "Cannot run SELECT INTO in this database. The database owner must run sp_dboption to enable this option"

I did run the 'exec sp_dboption', still it doesnt work.
Is there a solution for this.

Thanks,
VNK.
 
You need to provide parameters for sp_dboption.

exec sp_dboption 'dbname', 'select into/bulkcopy', 'True' Terry L. Broadbent - DBA
Computing Links:
faq183-874 contains "Suggestions for Getting Quick and Appropriate Answers" to your questions in the SQL Server forum. Many of the ideas apply to all forums.
 
Tlbroadbent,

Thanks Man! It works, really cool.

-VNK.
 
Did you set the option to False after completing the Insert? Keeping the option on and allowing Bulk Inserts can cause Transation Log backups to fail. Terry L. Broadbent - DBA
Computing Links:
faq183-874 contains "Suggestions for Getting Quick and Appropriate Answers" to your questions in the SQL Server forum. Many of the ideas apply to all forums.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top