x

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

paws27284 gravatar image

paws27284
373 29 32 34

(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.

New code box

There's a new way to format code on the site - the red speech bubble logo will automatically format T-SQL for you. The original code box is still there for XML, etc. More details here.

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

SQL Server Central

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

Topics:

x1951
x943

asked: Aug 30, 2012 at 03:07 PM

Seen: 594 times

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