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.
| Author |
Topic |
|
rum23
Yak Posting Veteran
77 Posts |
Posted - 2009-01-27 : 13:27:46
|
| Can you please tell me what is wrong in this sql statement?INSERT INTO tblB(ID1, ID2, BudgetDate)VALUES (SELECT ID1, ID2, GetDate() as BudgetDate FROM tblA)I get 2 errors on executing this sql1. Incorrect syntax near the keyword 'SELECT'.2. Incorrect syntax near ')'.Thanks for your help |
|
|
sodeep
Master Smack Fu Yak Hacker
7174 Posts |
Posted - 2009-01-27 : 13:29:40
|
| [code]SELECT ID1, ID2, GetDate() as BudgetDateinto tblbFROM tblA[/code]or if table exists[code]INSERT INTO tblB(ID1, ID2, BudgetDate)SELECT ID1, ID2, GetDate() as BudgetDate FROM tblA[/code] |
 |
|
|
rum23
Yak Posting Veteran
77 Posts |
Posted - 2009-01-27 : 13:32:35
|
| hmm...that doesn't work because it tries to create tblB and tblB already exists. I basically want to get all the rows from tblA and insert them into tblB. |
 |
|
|
rum23
Yak Posting Veteran
77 Posts |
Posted - 2009-01-27 : 13:33:53
|
| oops! nevermind. Ignore my response.INSERT INTO tblB(ID1, ID2, BudgetDate)SELECT ID1, ID2, GetDate() as BudgetDate FROM tblAWorked!Thanks. |
 |
|
|
sodeep
Master Smack Fu Yak Hacker
7174 Posts |
Posted - 2009-01-27 : 13:35:32
|
| Put that query in Export/Import wizard instead for faster insert. |
 |
|
|
|
|
|
|
|