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
 General SQL Server Forums
 New to SQL Server Programming
 sql scripts for insertion of records

Author  Topic 

Anup Shah
Starting Member

14 Posts

Posted - 2006-01-24 : 16:19:30
i am executing this scripts in sql server2000

SELECT
'INSERT into temp values(data1, data2, data3)' +
'SELECT ' +
CONVERT(VARCHAR(20), temp2.data1) + ', ' + CONVERT(VARCHAR(20), temp2.data2) + ', ' + '''' + CONVERT(VARCHAR(20), temp2.data3) + ''''
FROM temp, temp2
order by temp2.data1


now my table temp and temp2 both has folowing fields and data type

data1 int
data2 int
data3 varchar(20)

befor execution i have 0 records in temp and 10 records in temp2.
this scripts supposed to add all 10 records from temp2 to temp but it does nothing. evevn it is not giving error too.

SamC
White Water Yakist

3467 Posts

Posted - 2006-01-24 : 17:48:24
You should not quote the T-SQL. Looks like the SQL was taken from an EXEC and inserted in a SELECT.

Try

INSERT INTO MyTable (cola, colb, colc)
SELECT resulta, resultb, resultc
FROM MyTable
Go to Top of Page

Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)

7020 Posts

Posted - 2006-01-24 : 22:02:54
Do not cross post:
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=60803


CODO ERGO SUM
Go to Top of Page
   

- Advertisement -