Showing posts with label dynamically. Show all posts
Showing posts with label dynamically. Show all posts

Wednesday, March 28, 2012

How to use wildcards in WHERE clause

I have a SQL statement which is generated dynamically. I need to know what is the correct syntax for this

WHERE status = 'open' AND salesman = * AND dat = * AND customername = *

i.e. fetch everything WHERE status = 'open'

I know that simply WHERE status = 'open' would do the trick but I need it like the first example because of the way the statement is being generated i.e. this salesmen bit is like this.

If Salesman <> "*" Then
sql2 &= " AND salesman = '" & Salesman & "'"
Else
sql2 &= " AND salesman = *"
End If

Thanks

BenI presume you are saying that the salesman should be LIKE anything.

You should try:

WHERE status = 'open' AND salesman LIKE '%' AND dat LIKE '%' AND customername LIKE '%'

OleDb uses % as the wildcard character, and you need to use LIKE with wildcards.|||Yes, thats done the trick.

Thanks a lot.

Ben

Monday, March 12, 2012

How to use multiple configuration files?

Hi everyone,

How to change dynamically the connection properties for a DTSX?

Imagine that you launch a SSIS and under a several rules the same connection is reused with four or five different databases.

I know that I can attach a configuration file or more than one but how to tell to SSIS which use in every moment?

Thanks in advance and regards,

enric vives wrote:

Hi everyone,

How to change dynamically the connection properties for a DTSX?

Imagine that you launch a SSIS and under a several rules the same connection is reused with four or five different databases.

I know that I can attach a configuration file or more than one but how to tell to SSIS which use in every moment?

Thanks in advance and regards,

Do you mean you need to execute the same package multiple times but assigning different connection strings to connection managers on every execution?

|||Assign the InitialCatalog property of your connection object to a variable using expressions, and then make a Script task that sets the variable property depending on your condition.

I think it'd be better if you could just set one username/password for all databases so that you'll only need one config file for them all. This is only a problem if the passwords are all different (which I suspect them to be).|||Thanks for that.