Wrox Programmer Forums
|
SQL Server 2000 General discussion of Microsoft SQL Server -- for topics that don't fit in one of the more specific SQL Server forums. version 2000 only. There's a new forum for SQL Server 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Server 2000 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 6th, 2004, 01:20 PM
Authorized User
 
Join Date: Apr 2004
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts
Default select into

select * INTO db2..t1 from db1..t1

I get:
Server: Msg 2714, Level 16, State 6, Line 2
There is already an object named 't1' in the database.

't1' does exist, I can't delete it, i just wnat to select into it !





 
Old June 6th, 2004, 11:06 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 996
Thanks: 2
Thanked 11 Times in 11 Posts
Send a message via Yahoo to melvik
Default

What is it?! [u]Select</u> HAS no INTO what do u want to do?!

Always:),
Hovik Melkomian.
 
Old June 7th, 2004, 07:17 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
Default

Hello,

Try select * into db2.dbo.t1 from db1.dbo.t1

Please note that the user performing the insert operation must have dbo privileges to insert into a different database.

Brian
 
Old June 7th, 2004, 09:06 AM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

If you want to "SELECT INTO..." an existing table, try INSERT:

INSERT INTO db2..t1
SELECT * FROM db1..t1
 
Old June 7th, 2004, 08:08 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

Hi Ginoitalo,

Select * INTO .... copies the structure and rows from an exisiting table/given QUERY to a non exisiting target table. In this case the target table is created and should not pre-exist.

Insert INTO .... Copies only the rows from the QUERY that follows.
In this case the target table should exist(atleast the structure) to have the rows copied into.

Melvik,
Select has an INTO clause in it. With INTO, it the output of the query is destined to a table mentioned after INTO. Pls check BOL under Index "SELECT : Clauses" >> "described".

Code:
SELECT select_list
[INTO new_table_]
FROM table_source
[WHERE search_condition]
[GROUP BY group_by_expression]
[HAVING search_condition]
[ORDER BY order_expression [ASC | DESC] ]
Hope that helps.
Cheers!

_________________________
-Vijay G
Strive for Perfection





Similar Threads
Thread Thread Starter Forum Replies Last Post
Select row in GridView WITHOUT using Select button rao965 ASP.NET 2.0 Professional 1 February 15th, 2008 10:44 AM
Select from another select statement to a repeater simsen ASP.NET 2.0 Professional 0 May 2nd, 2007 04:34 PM
Fill select box and select recordset value markd Classic ASP Databases 1 February 20th, 2006 06:41 PM
select="node1", select="node2"... Baldo XSLT 7 March 12th, 2004 10:38 AM
Select Within A Select Problem vinyl-junkie Classic ASP Databases 6 June 7th, 2003 04:31 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.