| | |
two select statements in one insert statement
Please support our MS SQL advertiser: Intel Parallel Studio Home
Thread Solved |
sql Syntax (Toggle Plain Text)
IF OBJECT_ID('TestTable', 'U') IS NOT NULL DROP TABLE TestTable CREATE TABLE TestTable ( Col1 VARCHAR(30), Col2 VARCHAR(30) ) INSERT INTO TestTable (Col1, Col2) VALUES ('a', 'b') GO IF OBJECT_ID('tempdb..#Temp', 'U') IS NOT NULL DROP TABLE #Temp CREATE TABLE #Temp ( Col1 VARCHAR(30), Col2 VARCHAR(30) ) GO --Now we have our test data setup INSERT INTO #Temp (Col1, Col2) SELECT (SELECT Top 1 Col1 FROM TestTable) As Col1, (SELECT Top 1 Col2 FROM TestTable) As Col2 SELECT * FROM #Temp
This is the same question you asked in:
http://www.daniweb.com/forums/thread210160.html
I will respond on the original thread.
http://www.daniweb.com/forums/thread210160.html
I will respond on the original thread.
![]() |
Similar Threads
- The INSERT statement conflicted with the FOREIGN KEY constraint (MS SQL)
- Need Help on merge table (MySQL)
- SQL Insert statement syntax (Visual Basic 4 / 5 / 6)
- Nested Select statements (Oracle)
- insert statement problem (C#)
- problem with insert statement (ASP.NET)
- Syntax error in INSERT INTO statement (Java)
- insert statement error (MySQL)
- Its really a problem on INSERT statement (MySQL)
Other Threads in the MS SQL Forum
- Previous Thread: nested select in select clause
- Next Thread: Stored procedure and datatype TEXT (ASP)
| Thread Tools | Search this Thread |






I put from at the end 