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)
 Copy and Paste Rows

Author  Topic 

doggi3
Yak Posting Veteran

62 Posts

Posted - 2004-09-01 : 04:34:56
I have two tables here. Can I simply highlight the table and select all rows and copy it into another table?

I tried. But the result all ends up in one single column. How do I get it to work?

- HELP -

timmy
Master Smack Fu Yak Hacker

1242 Posts

Posted - 2004-09-01 : 04:48:41
Depends on your front-end app. Multi-row cut & paste works fine in Access.

Go to Top of Page

doggi3
Yak Posting Veteran

62 Posts

Posted - 2004-09-01 : 04:49:55
I am using SQL Server Enterprise Manager... Can it be done?

- HELP -
Go to Top of Page

doggi3
Yak Posting Veteran

62 Posts

Posted - 2004-09-01 : 05:16:32
I actualli want to copy rows from Table A(Ocma_2900113_PH_UTF8_8_27_2004_7000) to Table B(ocma_2900114_PH_UTF8_8_27_2004).

To show rows from Table B (ocma_2900114_PH_UTF8_8_27_2004), I use the following query:

Select *
FROM ocma_2900114_PH_UTF8_8_27_2004
WHERE ((EMAIL_ADD_NM + PERS_LAST_NM) NOT IN
(SELECT email_add_nm + pers_last_nm
FROM Ocma_2900113_PH_UTF8_8_27_2004_7000))

So, in order to insert these rows into Table A (Ocma_2900113_PH_UTF8_8_27_2004_7000), do I do this query:

INSERT INTO Ocma_2900113_PH_UTF8_8_27_2004_7000
Select *
FROM ocma_2900114_PH_UTF8_8_27_2004
WHERE ((EMAIL_ADD_NM + PERS_LAST_NM) NOT IN
(SELECT email_add_nm + pers_last_nm
FROM Ocma_2900113_PH_UTF8_8_27_2004_7000))

- HELP -
Go to Top of Page

timmy
Master Smack Fu Yak Hacker

1242 Posts

Posted - 2004-09-01 : 05:30:06
So you're not using a cut & paste then?
For your insert query, you should specify a field list in the insert, and also specify the fields in the SELECT.
Go to Top of Page

doggi3
Yak Posting Veteran

62 Posts

Posted - 2004-09-01 : 05:35:24
I want to use cut and paste. It is much easier this way. But I will like to ask if it is possible in SQL Server Enterprise Manager.

If I realli can't use cut and paste, then I will have to use query. But I have 103 columns in each table. So I have to type out the column names one by one?

- HELP -
Go to Top of Page

benjamintb
Starting Member

15 Posts

Posted - 2004-09-01 : 06:04:39
Could you just copy the entire table and then rename it? if you have less than 103 fields in the table already maybe its easier to copy any other fields that you need to add later by using insert?
Go to Top of Page

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2004-09-01 : 06:14:18
well you dont need to write all 103 colums by hand :)))

this wil give you a CSV string of column names in the table

Declare @ColumnList varchar(1000)
SELECT @ColumnList = COALESCE(@ColumnList + ', ', '') + column_name
FROM INFORMATION_SCHEMA.Columns
WHERE table_name = 'TableName'
--and Ordinal_position between 0 and 20
SELECT @ColumnList

Go with the flow & have fun! Else fight the flow :)
Go to Top of Page

rockmoose
SQL Natt Alfen

3279 Posts

Posted - 2004-09-01 : 09:01:30
To avoid typing:
In QA, expand the table, drag and drop the Columns folder into the workarea.
spirit1's suggestion is also good :-).

Please, don't do Copy/Paste, it is not easier.
When You feel more confident with T-SQL, that is the way to do this.

So did You solve the data problems/issues ?

rockmoose
/* Chaos is the nature of things...Order is a lesser state of chaos */
Go to Top of Page
   

- Advertisement -