Netezza : Update error : cross database connection not supported for this type of command - netezza

I am trying to update a table in Netezza getting below error
"Update table table1
set col1 = val1
where col2 = "xx"
I am getting below error :
"Netezza : cross database connection not supported for this type of command "
what could be the possible reason

You need to ‘switch’ to the database where the ‘table1’ is located. Many people connect to the SYSTEM database, but it’s a bad idea to put your tables/views there. In this example, I assume that table1 is in the EDW database:
Set catalog EDW
;
Update table table1 set col1 = val1 where col2 = ‘xx’
;
I hope that makes sense to you?

Related

MSSQL - Invalid object name when attempting an update

I have a table in SQL that I can query easily when running SELECT * FROM Scheme.Table1
There are no Intellisense errors and I can see the table in the list of tables under the database
If I attempt to run an UPDATE against the table, I get the error
Msg 208 Invalid object name 'Table1'
Updates against other tabes within the same scheme all work fine
What could be causing this error? Is the wording misleading and it is really something else?
EDIT: update statement is...
UPDATE SCHEMA.TABLE1 SET SCH1 = 'DB', SCH2 = '1' WHERE MEMBERNO = 123999
All fields are correct and exist on the table
Thanks to the comments, it was a trigger on the table that was referencing itself without the SCHEMA (I was logged in using Windows Authentication)

Why nested SQL inside OLE DB Source not work?

I'm developing a SSIS package to perform extractions from SQL Server 2008 to an Excel file.
This is my data flow:
"Extraction of concepts" is an OLE DB Source. It executes this SQL statement:
SELECT
Id,
Name,
Surname,
(
SELECT
CI.Interest + '; '
FROM
CustomerInterests CI
WHERE
CI.CustomerId = C.ID
FOR XML PATH ('')
) AS Interest
FROM
Customer C
WHERE Id = ?
When I try to save my query I get this error:
If I modify my SQL Statement like following, the error does not appear:
SELECT
Id,
Name,
Surname,
NULL AS Interest
FROM
Customer C
WHERE Id = ?
Can you help me?
Thanks
In order to achieve what you want, follow the below steps:
1) Add variable in SSIS called ID
2) In your WHERE Statement
Use : WHERE #Id = ?
3) Assign the #ID varible in Data flow with ID SSIS varibale.
Updated:

SSIS 2010 update table with decimal data type gives error "type not supported.DBTYPE_DECIMAL"

Strange error, Using SSIS 2010 on 2012 Enterprise Edition db.
Using OLEDB connection.
Variable a,b,c are defined as Decimal in ssis.
d is defined as a String.
Sql Task:
Select min(col1),max(col1) from table_a
where key_value = ?
where: parameter 0 is d , data type=Varchar
resultset 1 is a , 2 is b
Expression task:
#[User:c] = (DT_DECIMAL,2) (#[User:a] + #[User:b])
Sql Task:
Update table_a
set col2 = ?
where key_value = ?
where: parameter 0 is c (DataType=DECIMAL) and 1 is d (DataType=Varchar)
Error: ... failed with the following error: "The type is not
supported.DBTYPE_DECIMAL". Possible failure reasons: Problems with
the query, "ResultSet" property not set correctly, parameters not
set correctly, or connection not established correctly.
table_a is defined as
d varchar(4),
col1 numeric(10,2),
col2 numeric(10,2)
There are multiple rows of d and no index on table...
I've tried casting and converting the value in the update statement
Any ideas what's in error ?
Thanks
Check the parameter mapping section of your SQL task(s) to ensure the parameters are set properly.
I've seen this before, 'parameter not set correctly' is the key.

Update database table from one SQL Server database table to another?

I am trying to update database fields from one SQL Server table to another.
Our production SQL Server is [spdbprod.test.com\spprod], our QA server is [spdbQA.test.com\spQA].
I need to update table in production from QA table. I using this SQL statement but, it is giving an error.
UPDATE
[spdbprod.test.com\spprod].[aspnetdb].[dbo].[Communities_Groups] as t1
SET
t1.Show = (Select t2.show from [spdbQA.test.com\spQA].[aspnetdb].[dbo].
[Communities_Groups] as t2 where t1.GroupID = t2.GroupdID)
What I am missing here?
Error:
UPDATE. ("Incorrect syntax near the keyword 'as'.")
You are using table alias in a wrong way. You cannot do UPDATE table1 t SET field1=val, you have to write UPDATE table1 SET field=val (Or UPDATE table1 SET field=val FROM table1 t). So change your query to
UPDATE [spdbprod.test.com\spprod].[aspnetdb].[dbo].[Communities_Groups]
SET Show = t2.show
FROM [spdbprod.test.com\spprod].[aspnetdb].[dbo].[Communities_Groups] t1
INNER JOIN [spdbQA.test.com\spQA].[aspnetdb].[dbo].
[Communities_Groups] t2 ON (t1.GroupID = t2.GroupID)
I know this has been answered already but this worked for me.
Add a Linked Server under Server Objects | Linked Servers:
Microsoft documentation.
Name the Linked Server [SERVER-NAME or <some ipaddress>, <some-port>]
e.g. [10.0.0.200,2345] - I am using port 2345 but the standard MS SQL port is 1433.
Example:
We have a [Customers] table
We want to update [CustomerAddress]-field for CustomerId = 123
We want to use backup data from a server called [backupServer]
The [backupServer] is the machine where we execute the SQL
This is the SQL-code:
UPDATE production
SET
CustomerAddress = backupServer.CustomerAddress
FROM
[10.0.0.200,2345].[ProductionDatabase].[dbo].[Customers] production
INNER JOIN
[BackupDatabase].[dbo].[Customers] backupServer
ON
production.CustomerId = backupServer.CustomerId
WHERE
backupServer.CustomerId = 123
Generalized format:
UPDATE production
SET
columnName = backupServer.columnName
FROM
[SERVER-NAME or IP,PORT].[ProductionDatabase].[dbo].[tableName] production
INNER JOIN
[BackupDatabase].[dbo].[tableName] backupServer
ON
production.SomeId = backupServer.SomeId
WHERE
backupServer.SomeId = <id>
I believe you have to have a database link (linked servers) for this to work.
I do not have access to two SQL servers here at work so I cannot test it, but I sure that you need the link.
Do you have a linked server setup?
Here is a URL that may help
http://msdn.microsoft.com/en-us/library/ms188279.aspx
You need to add a Linked Server under Server Objects
You can name that Linked Server either with "CHOOSEN-NAME" or
[ipaddress , port number]
how to add a linked server using tsql , please check this link : how to find linked server
for an example purpose suppose i have named the linked server
"DESTINATION_SERVER" , database name is "DESTINATION_DB" and table
name is "DESTINATION_TBL". then from your source server your query could be like this below:
UPDATE t1
SET t1.updatecolumn = t2.updatecolumn
FROM [DESTINATION_SERVER].[DESTINATION_DB].[dbo].[DESTINATION_TBL] t1
INNER JOIN [SOURCE-SERVER].[SOURCE_DB].[dbo].
[SOURCE_TBL] t2 ON (t1.matcingcolumn = t2.matchingcolumn)

SQL Update across Linked Server

I have a Linked Server set up on my host Server: "MyLinkedServer"
I have an SP on my server "HostServer".
I am calling a stored proc on HostServer that updates a table in DatabaseA on MyLinkedServer with values from a table in DatabaseB on MyLinkedServer.
I have other SPs that run fine in the same scenario, but they are doing inserts and deletes, however this SP fails to update the table in DatabaseA (no error returned, just no changed data), and if I change connections to actually run the SP on "MyLinkedServer" it works without a problem.
UPDATE MyLinkedServer.DataBaseA.dbo.MyTable
SET Column1 = db2.Column1
FROM MyLinkedServer.DataBaseA.dbo.MyTable db1
INNER JOIN
(
SELECT TOP 1 Column1
FROM MyLinkedServer.DataBaseB.dbo.MyTable db2
WHERE db2.Id = 2
) AS db2 ON db2.Id = 2
WHERE db1.Id = 1
I believe you'll need to reference the alias you reference in the from statement. Does changing
UPDATE MyLinkedServer.DataBaseA.dbo.MyTable
into
UPDATE db2
fix your issue?

Resources