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 2005 Forums
 SSIS and Import/Export (2005)
 Insert Multiple Values Using Expression

Author  Topic 

qman
Constraint Violating Yak Guru

442 Posts

Posted - 2010-11-16 : 10:02:56
I am trying to insert multiple values at one using a SQL Task Expresion. Does anyone see anything wrong with my syntax?

"INSERT INTO dbo.aaa (a, b, c, d, e)
VALUES('aaa', 'bbb', 7," + (DT_WSTR, 500) @[User::aaa_count] + ", getDate()),
VALUES('aaa', 'bbb', 7," + (DT_WSTR, 500) @[User::bbb_count] + ", getDate()),
VALUES('aaa', 'bbb', 7," + (DT_WSTR, 500) @[User::ccc_count] + ", getDate()),
VALUES('aaa', 'bbb', 7," + (DT_WSTR, 500) @[User::ddd_count] + ", getDate())"

When I run the SSIS package, it fails with the following:

"....failed with the following error: "Incorrect syntax near ','.". Possible failure reasons: Problems with the query, "ResultSet" property not set correctly, parameters not set correctly, or connection not established correctly."

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2010-11-16 : 10:48:57
I believe this kind of multiple values is possible in 2008 but not earlier...
And the value for column d should be inside single quotes I think...

Try this instead:
INSERT INTO dbo.aaa (a, b, c, d, e)
select 'aaa', 'bbb', 7,'" + (DT_WSTR, 500) @[User::aaa_count] + "', getDate()) union all
select 'aaa', 'bbb', 7,'" + (DT_WSTR, 500) @[User::bbb_count] + "', getDate()) union all
select 'aaa', 'bbb', 7,'" + (DT_WSTR, 500) @[User::ccc_count] + "', getDate()) union all
select 'aaa', 'bbb', 7,'" + (DT_WSTR, 500) @[User::ddd_count] + "', getDate())



No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

qman
Constraint Violating Yak Guru

442 Posts

Posted - 2010-11-16 : 12:27:33
Thanks, ended up using individual SQL task with a separate insert statement for the needed inserts. Stuck on SQL 2005 for now.
Go to Top of Page
   

- Advertisement -