SQL 2019 : Invalid data for UTF8-encoded characters - sql

When attempting to run the following statement :
sp_change_users_login 'auto_fix','ELC',NULL,'CLE'
I get the following error :
sp_change_users_login, Line 218 [Batch Start Line 2]
Invalid data for UTF8-encoded characters
The number of orphaned users fixed by updating users was 0.
This is a SQL 2019 with UTF8 enabled.

as it has been mentioned in the comment that proc has been deprecated, you can use modern command alter user:
ALTER USER JEANC
WITH PASSWORD = 'cnaej'

Related

How to split a large query in command line?

I installed oracle db version 19c in my docker environment and set up a database filled with dummy data. However, when I try to run a very large query I get the error:
SP2-0341: line overflow during variable substitution (>3000 characters at line 1).
I tried splitting it up with linebreaks but depending on how I split it I get all kinds of errors like:
ERROR at line 2: ORA-00933: SQL command not properly ended
or
ERROR at line 2:
SP2-0341: line overflow during variable substitution (>3000 characters at line 3)
The query is formatted as
SELECT AA.n_name AS AA_n_name, AA.n_nationkey AS ...
FROM nation AS AA FULL OUTER JOIN supplier...
WHERE (AC.p_partkey = ... AND...) OR((AC.p_partkey = ...)); -- The where part is over 5000 characters long--
Is there an alternative or solution to tackling this in the command line? I tried running the query as a sql file as well and hit a 4999 limit. I am on a Ubuntu server if that would help and any assistance would be appreciated.
It depends on the environment that you're working in, but generally you are able to continue a command onto the next line by ending the line with a 'back slash' \.

Token unknown in SQLCODE

CREATE DATABASE test.fdb -user ZZZZZ -password *******;
I am using above command to create a database for my project in windows 7. I am new to Firebird SQL, I used my system credentials for log in but it is showing some error. So, How can I reset my password?
SQL error code = -104
Token unknown.
I don't even know the significance of SQLCODE = -104.
The error shown is not caused by not knowing the database password, you have a syntax error in the CREATE DATABASE statement. The error Token unknown means that the statement parser read something it didn't expect; the error is usually followed by the offending token.
If I execute your statement using ISQL on Firebird 3.0, I get the following full error:
SQL> CREATE DATABASE test.fdb -user SYSDBA -password *******;
Statement failed, SQLSTATE = 42000
SQL error code = -104
-Token unknown
-test
Which means that at (or before) test something in your query is wrong.
The right syntax for CREATE DATABASE is:
CREATE {DATABASE | SCHEMA} '<filespec>'
[USER 'username' [PASSWORD 'password']]
[PAGE_SIZE [=] size]
[LENGTH [=] num [PAGE[S]]
[SET NAMES 'charset']
[DEFAULT CHARACTER SET default_charset
[COLLATION collation]] -- not supported in ESQL
[<sec_file> [<sec_file> ...]]
[DIFFERENCE FILE 'diff_file']; -- not supported in ESQL
<filespec> ::= [<server_spec>]{filepath | db_alias}
<server_spec> ::= servername [/{port|service}]: | \\servername\
<sec_file> ::= FILE 'filepath'
[LENGTH [=] num [PAGE[S]] [STARTING [AT [PAGE]] pagenum]
In other words your statement should be:
create database 'test.fdb' user SYSDBA password '*******';
So:
Quotes around the path to the database file (or alias)
No - before the user and password clause
Quotes around the password (contrary to the syntax shown, quotes are optional around the user name)
As an aside, the SQL error code is usually not very interesting (as some of them can cover several different errors).

Running db2 from bash script not working?

I'm currently using bash on CentOS. DB2 is installed and db2 is on my path.
I have a few lines in a script which are supposed to update my db2 database, but they aren't working. As a minimal reproduction, I can do the exact same thing right in the bash command line and get the same error. Here's that reproduction:
$ db2 connect to PLT02345 user uni using uni; db2 update USM_USER set STATUS = 1 where NAME = 'asm_admin'
I expect this to set STATUS to 1 for everything in PLT02345.USM_USER where the NAME is currently asm_admin.
Instead, I get an error about "ASM_ADMIN" not being valid in the context where it's used. Here's the full output:
Database Connection Information
Database server = DB2/LINUXX8664 10.1.2
SQL authorization ID = UNI
Local database alias = PLT02345
DB21034E The command was processed as an SQL statement because it was not a
valid Command Line Processor command. During SQL processing it returned:
SQL0206N "ASM_ADMIN" is not valid in the context where it is used.
SQLSTATE=42703
I'm confused - what about this makes it not valid? Is bash somehow mutilating the command and not passing everything as it should to db2?
If you're running this from the command line, Bash will drop the 's off 'asm_admin' because it simply assumes you're passing a string. The end result is the SQL becoming WHERE name = asm_admin which is invalid.
To correct this, you need to quote your whole command:
db2 "update USM_USER set STATUS = 1 where NAME = 'asm_admin'"

Why is this SQL Update failing ("column name is not valid")?

I've got a SQL Server CE table like so:
...and I'm trying to update its solitary record like so:
update workTables
set fileType = "INV"
Yet I get:
Why?
UPDATE
Please see a related question here
Here check Microsoft support for yor error.
http://support.microsoft.com/kb/825392
This is from the site:
SYMPTOMS:
When you run a query on a Microsoft SQL Server 2000 Windows CE Edition version 2.0 database, and the query has a column that contains one or more space characters, the query may not be successful. Additionally, you may receive the following error message:
FAILED: select <Column Name> from <Table Name>
Error: 0x80040e14 DB_E_ERRORSINCOMMAND
Native Error: (25503)
Description: The column name is not valid. [,,,Node name (if any),Column name,]
Interface defining error: IID_ICommand
Param. 0: 0
Param. 1: 0
Param. 2: 0
Param. 3:
Param. 4: col1
Param. 5:
RESOLUTION:
To resolve this problem, enclose the column name that contains spaces in quotation marks (" "), and then run the query. For example, you can run the following query, and the query results are displayed successfully:
SELECT "col1 " FROM testtable
Your query should be:
update [workTables]
set [fileType] = 'INV'
Note: single quotes ^^^^

MySQL Dump Error 1064 (42000)

I'm having a MySQL dump from Version 4.0.21. I converted it to UTF-8 to fit with the special characters such as (Ü, ü, Ä, ä, Ö, ö, ß). Now I have to import it into the latest MySQL Version 5.5.36. All data have been imported but an error occurred at the end.
ERROR 1064 (42000) at line 80769: You have an error in your SQL syntax...use near '' at line 1
The empty string and the line numbers are confusing me. Importing with phpMyAdmin results the same as command line does, with the command:
mysql -u root -p bugtracker < E:\mantisUTF.dump
The import with the original dump from Version 4.0.21 is working perfect but without the above mentioned special characters.
First Lines of the dump file:
-- MySQL dump 9.11
--
-- Host: localhost Database: Mantis
-- ------------------------------------------------------
-- Server version 4.0.21-debug
--
-- Table structure for table `mantis_bug_file_table`
--
Last Lines (80768 & 80769):
INSERT INTO mantis_user_table VALUES (57,'fullName','firstName lastName','emailAdress','dd1875c93e8f17a24ebaf9c902b7165a','2014-01-29 13:43:21','2014-03-26 13:22:47',1,0,55,14,0,0,'1b886436b0c62598ab66e40ae89f0c016dc5777ebb601a73f2a07536281113ae'
Thanks in advance.
Relax
By rechecking my question i found the problem. The problem was a missing ')' at the end of the dump file.
Last line:
INSERT INTO mantis_user_table VALUES (57,'fullName','firstName lastName','emailAdress','dd1875c93e8f17a24ebaf9c902b7165a','2014-01-29 13:43:21','2014-03-26 13:22:47',1,0,55,14,0,0,'1b886436b0c62598ab66e40ae89f0c016dc5777ebb601a73f2a07536281113ae')