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 2000 Forums
 Import/Export (DTS) and Replication (2000)
 Select Statement using Global Variables

Author  Topic 

JuniorProgrammer
Starting Member

10 Posts

Posted - 2003-08-26 : 14:00:45
I am attempting to export data using the query below to an Access database. The intClient is a global variable that I have setup in the DTS package. When I execute the process, I receive an error 'Error converting data type varchar to numeric'. I have checked the table the global variable and the table used in the select statement and they are both set to numeric. Can a global variable be used in a select statement?

SELECT * from Activity WHERE BankID= '" & intclient & "'

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2003-08-26 : 14:04:43
This might work (or maybe you would need to convert the right side of the equal to numeric):

SELECT * from Activity WHERE CONVERT(VARCHAR(50), BankID) = '" & intclient & "'

The problem is that the right side of the equal is varchar and BankID is numeric. So you need to convert one of them.

I do not know if this will work for Access.

Tara
Go to Top of Page

JuniorProgrammer
Starting Member

10 Posts

Posted - 2003-08-26 : 14:32:06
I am no longer receiving the error message. However, the select statement is not pulling any data. Do I have the syntax for the global variable correct?
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2003-08-26 : 19:02:02
Have a look at this:

[url]http://www.sqldts.com/default.aspx?205[/url]

Tara
Go to Top of Page
   

- Advertisement -