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)
 Using variables in SQL task

Author  Topic 

Bex
Aged Yak Warrior

580 Posts

Posted - 2009-03-02 : 09:56:25

Hi There

I have 2 variables, one to store the results of a table and the other, a parameter.

When I try and reference the variables in a Execute SQL Task:

SELECT TableSchema+'.'+TableName FROM admin.GetTableNames (NULL, 'crdm','template') tbls
INNER JOIN [User::GetPartitionDates] dates ON dates.PartitionDate = tbls.PartitionDate
WHERE tbls.TemplateObjectID = [User::TemplateObjectID]

I get the following error:

failed with the following error: "Invalid object name 'User::GetPartitionDates'.".

What am i doing wrong?

Thanks

Hearty head pats

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-03-02 : 10:48:42
you need to use expression builder to build the query

SELECT TableSchema+'.'+TableName FROM admin.GetTableNames (NULL, 'crdm','template') tbls
INNER JOIN '+ @[User::GetPartitionDates] +' dates ON dates.PartitionDate = tbls.PartitionDate
WHERE tbls.TemplateObjectID = '+ @[User::TemplateObjectID]

then store this tring in another variable and use it as source of sql task.

Go to Top of Page

Bex
Aged Yak Warrior

580 Posts

Posted - 2009-03-02 : 11:22:21
Thanks muchly!!

Got it working now!!



Hearty head pats
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-03-02 : 13:09:59
welcome
Go to Top of Page
   

- Advertisement -