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 2008 Forums
 Transact-SQL (2008)
 insert data from temp table into table in database

Author  Topic 

Junior Sqler
Starting Member

18 Posts

Posted - 2013-05-09 : 06:00:29
Hi!
My question is the following i have created a table in database:

Create table status
(
A int,
B VARCHAR(20),
C VARCHAR(20),
D varchar(20) )

and i want to fill it in with data from a temp table (#temp):

insert into status (A,B,C,D)
select( a.A,a.B,a.C,'oK')
from #temp a

but the following message appears:
Incorrect syntax near ',' (in line with select)

What is wrong? Could anyone help me?

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2013-05-09 : 07:02:17
it should be

insert status (A,B,C,D)
select A,B,C,'OK'
from #temp


------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page

Junior Sqler
Starting Member

18 Posts

Posted - 2013-05-09 : 07:27:34
thank you!!
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2013-05-09 : 07:33:52
welcome

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page
   

- Advertisement -