x
login about faq Site discussion (meta-askssc)

Execute SQL task returning output variables

I am trying to use the Execute Sql Task to retrieve specific date values from the database that are assigned to package variables. Here is what I have set in the General Setting tab: alt text

The SQL statement is

Select 
Left(Convert(Varchar,(DateAdd(mm,-1,GetDate())),112),6) + '16' as ?,
Left(Convert(Varchar,GetDate(),112),6) + '15' as ?

The User::BegDate and Use::EndDate are defined as strings. Here is the parameters tab: alt text

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

When I execute the statement like this in SQL Query window it returns the values I expect

Select 
Left(Convert(Varchar,(DateAdd(mm,-1,GetDate())),112),6) + '16' as BegDate,
Left(Convert(Varchar,GetDate(),112),6) + '15' as EndDate

I find lots of help regarding input variables, but not output variables. Can you help?

Thanks! paws27284

more ▼

asked Aug 30 '12 at 03:07 PM in Default

paws27284 gravatar image

paws27284
243 11 20 26

(comments are locked)
10|1200 characters needed characters left

0 answers: sort voted first
Be the first one to answer this question
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments



Facebook logo Follow Ask SSC on Facebook
Find Ask SSC on Google+
linkedin logo Find us on LinkedIn

Topics:

x1843
x758

asked: Aug 30 '12 at 03:07 PM

Seen: 284 times

Last Updated: Aug 30 '12 at 03:07 PM

Copyright © 2002-2012 Simple Talk Publishing. All Rights Reserved. If you have any queries, please contact the site administrators.
Ask SQL Server Central is a community service provided by Red Gate.