AspenTech InfoPlus 21 - How to select a NULL value? - database

I'm trying to select a null value on a IP21 Database like we do in Oracle databases or Sql Server, e.g:
Oracle: SELECT NULL FROM DUAL
Sql Server: SELECT NULL
Anyone know how i can do this?

Related

SQL Server 2008 R2: Query MS Access from SQL Server

Want to retrieve records from Access through linked server in SQL Server and need to convert/cast the column with VARCHAR for some constraint.
My attempt:
SELECT Cola, Colb
FROM MSAccess_LinkedServer...TableName
WHERE CAST([Cola] AS VARCHAR) = 'A123'
Unable to get the result from above query.
But when I remove CAST then I will get the result, but I want to know how to put the cast/convert.
No casting should be needed for text. How about simply:
WHERE [Cola] = 'A123'

COALESCE: SQL Server vs Oracle

I have following script:
SELECT 1
FROM Table t
WHERE COALESCE(NULL, t.ID) = NULL;
t is empty. The query returns 1 for Oracle and it returns nothing for SQL Server.
What is an output of COALESCE operation for SQL Server? Can we fix this code to behave for both DB in the same way?
What's the point of having colaesce here as your first argument is NULL.
Just do this:
SELECT 1
FROM Table t
where t.ID IS NULL;
The problem is not the Coalesce function. If the t table is empty then no rows will be found and returned by SQL Server.

SSIS Migrating data from Oracle to SQL Server. Need to find dates before '1900-01-01' and replace with null

I'm trying to migrate data from a Oracle database to SQL Server. The query has invalid dates so I want to change the invalid dates to NULL when I place them in the SQL Server 2012. I'm using SSIS and I'm trying to create a derived column to handle it for me but I can't get the expression right.
The expression I have is :
[Date_Column] < 1900-01-01? NULL(DT_WSTR,50) : [Date_Column]
This is not the only syntax I tried, I also tried
[Date_Column] < "1900-01-01"? NULL(DT_WSTR,50) : [Date_Column]
[Date_Column] < (DT_DBDATE)1900-01-01? NULL(DT_WSTR,50) :[Date_Column]
And many others.
Is there a better way to do this?
I'm not too familiar with PL/SQL but if you have a way for me to just edit it in the query rather than using a transformation that would be great!
Also, when I'm trying to migrate the data from Oracle to SQL Server using SSIS, it fails and throws out a data format error. All I am doing is putting the data into a staging table in SQL Server (using an OLE DB source connected to OLE DB destination). The data types are just DB_TIMESTAMP but it won't complete. It will only load 1/4th of the data.
Thank you!
On the Oracle side you can turn dates earlier than 1900-01-01 into NULL values with a CASE expression in your query, e.g.
with t as (
select date '1000-01-01' as date_column from dual
union
select date '2000-01-01' as date_column from dual)
select date_column,
case when date_column < date '1900-01-01' then null else date_column end new_column
from t
DATE_COLUMN NEW_COLUMN
----------- ----------
1000-01-01
2000-01-01 2000-01-01

INSERT INTO SELECT statement doesn't copy all selected records

I have two database, which are "OLD_DB" and "NEW_DB". I am trying to move data from OLD_DB to NEW_DB. I use script like below :
INSERT INTO [NEW_DB].[dbo].[Table1](Field1,Field2,Field3) SELECT Field1,Field2,Field3 FROM [Linkserver].[OLD_DB].[dbo].[Table1] WHERE Field4 = 1234
[Linkserver]: I use linked server because OLD_DB is in different server.
I added script above in SQL SERVER Agent, so it will trigger itself on 5:00PM. At 5:00PM, my users were still working with OLD_DB. After they(users) left, I came to check my NEW_DB by using script like below :
SELECT Field1,Field2,Field3 FROM [New_DB].[dbo].[Table1]
there are only 291 records. And I try to use SELECT statement in OLD DB
SELECT Field1,Field2,Field3 FROM [Linkserver].[OLD_DB].[dbo].[Table1] WHERE Field4 = 1234
There are 431 records. then it turn into question, why does number of record in OLD_DB and NEW_DB are different ?
NOTE : I use SQL SERVER 2012 for both server.

Oracle/SQL Server Database Link Date Format Issue

I have an Oracle hs database link set up between SQL Server 2012 and Oracle 11g.
When Selecting date columns in Oracle from the SQL Server database the date comes through fine but as soon as it has to pass through any function then the date gets cropped from 10 to 5 characters.
For example:
Select Input_Date from schema.table#Database
would return 2000-08-18
Select Len(Input_Date) from schema.table#Database
would return 5
(Select Input_Date from schema.table#Database1
Union
Select Input_Date from schema.table#Database2)
would return 2000-
I am at a loss at what to do, at first the select statement also returned 2000- but then I changed the NLS_DATE_FORMAT parameter which allows a view of the full date in a select statement but has not fixed any of the other issues.
When I select dump(input_date,1016) from schema.table#Database I get
Typ=1, Len=10, CharacterSet=AL16UTF16.
I would really appreciate some help as there seems to be very little information about this online.
Many thanks.

Resources