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

 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

 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, 2012 at 03:07 PM in Default

avatar image

433 34 41 43

(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



Answers and Comments

SQL Server Central

Need long-form SQL discussion? SQLserverCentral.com is the place.



asked: Aug 30, 2012 at 03:07 PM

Seen: 747 times

Last Updated: Aug 30, 2012 at 03:07 PM

Copyright 2018 Redgate Software. Privacy Policy