Showing posts with label fails. Show all posts
Showing posts with label fails. Show all posts

Friday, March 23, 2012

Help with a SQL Query

I have a if condition in a query for a columnA <> 1 but this columnA in the table is null and my IF query fails - How do I need to structure my query:
If rsX = 1 Or rsX = 2 AND columnA <> 1 Then
ANy help will be appreciated.
Thanks!!if you really did mean to connect columnA<>1 with rsX=2 then what you want is this --
select rsX
, columnA
, otherstuff
from yourtable
where rsX = 1
or (
rsX = 2
and ( columnA is null
or columnA <> 1
)
)if not, then you probably want this --
select rsX
, columnA
, otherstuff
from yourtable
where ( rsX = 1
or rsX = 2
)
and ( columnA is null
or columnA <> 1
)|||Thanks for your reply - Now I have rewritten my query as -
If ((rsX = 1 Or rsX = 2) AND (columnA is NULL OR columnA <> 1)) Then

I am getting a run time error 424 in VB -object required - Any ideas??|||nope, sorry, no idea, i don't know VB

however, you may want to try SELECT ... WHERE instead of IF ... THEN

you should let the database engine select just the rows you want

rudy|||What kind of variable is columnA?

VB only supports the Null value for certain data types.

Originally posted by sri2003
Thanks for your reply - Now I have rewritten my query as -
If ((rsX = 1 Or rsX = 2) AND (columnA is NULL OR columnA <> 1)) Then

I am getting a run time error 424 in VB -object required - Any ideas??|||Please post your entire SQL query, not just the IF clause.

blindman|||The variable for the column is Char.|||The SQL query is select all the records from the table it is a simple SQL - Something like Select a,b,c,d,e from tableDummy. The in VB is where I do the IF condition for the recordset that is:
If rsX = 1 Or rsX = 2 AND columnA <> 1 - do you want me to post the entire RecordSet - please let me know.
Thanks!|||Ok, the column is of type char, but a variable in VB of type String is not able to hold a Null value.

Is it a VBScript?

What are the variables declared as? (if they are explicitly declared)

Is there some reason you do not directly use the fields from the recordset in the comparison?
((rs.rsX = 1 Or rs.rsX = 2) AND (rs.ColumnA Is Null Or rs.ColumnA <> 1))

Also, as some suggested, it might be a better idea to do the entire filtering in the WHERE clause if possible.

Friday, March 9, 2012

Help using Lookup

Hi

I am trying to use lookup to see if a item esists in my table ( 3 key fields ). If the lookup fails I want to insert the records. If it succeeds I have put a recordcount to catch the items that are not required. I don't think that I understand the settings for failed rows. I have tried setting the Configure Error Output to redirect, but this does not seem to work. I have the below errors.

[SQL Server Destination [151]] Error: Unable to prepare the SSIS bulk insert for data insertion.

[DTS.Pipeline] Error: component "SQL Server Destination" (151) failed the pre-execute phase and returned error code 0xC0202071.

Can someone please advise me how to set up this component to work for my application

Thanks

ADG

SQL Server Destinations only work on the machine that have the actual SQL Server installed locally. Is this the case?|||

Hi Phil

I have SQL Server 2005 Developer Edition installed on a stand alone machine at the moment. Previous two task flows use a SQL Server Destination (same table) and work OK.

I did not know that I could not use a SQL Server Destination on a network. Eventually I will migrate my solution to one of our group servers, currently I am developing the solution, or rather battling to learn SQL server. I guess that maybe I should use another type of destination once the above bug is ironed out.

Regards

ADG

|||

Bug fixed

I deleted the Look up and set it up again and all is well. Not sure what i did first time, ( I fiddled with too many settings I suspect