Token unknown in SQLCODE - sql

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).

Related

SQL 2019 : Invalid data for UTF8-encoded characters

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'

Stored procedure on AIX environment and DYNAMICRULES BIND

I'm writing a stored procedure (on AIX environment) and I need to activate "DYNAMICRULES BIND" selected.
CREATE OR REPLACE PROCEDURE jjjjjj_PROVA
( IN p_input1 CHAR(2) )
LANGUAGE SQL
SPECIFIC jjjjjj_PROVA
DYNAMICRULES BIND
P1: BEGIN
...
...
END P1
In the distribution phase I get the following error.
xxxxx.jjjjjj_PROVA - Distribuzione avviata.
Creazione di procedura memorizzata restituzioni SQLCODE: -104, SQLSTATE: 42601.
xxxxx.jjjjjj_PROVA: 12: An unexpected token "BIND
P1" was found following "DYNAMICRULES". Expected tokens may include: "<space>".. SQLCODE=-104, SQLSTATE=42601, DRIVER=4.19.56
An unexpected token "BIND
P1" was found following "DYNAMICRULES". Expected tokens may include: "<space>".. SQLCODE=-104, SQLSTATE=42601, DRIVER=4.19.56
xxxxx.jjjjjj_PROVA - Distribuzione non riuscita.
xxxxx.jjjjjj_PROVA - Rollback completato correttamente.
The same statement in the DB2 Z / OS environment is correct.
Tips?
Thank you!!
Use CALL SET_ROUTINE_OPTS('DYNAMICRULES BIND') statement before CREATE PROCEDURE in the same session.
Customizing precompile and bind options for compiled SQL objects

Connecting to SQL Server using Perl using DBI?

I am trying to connect to SQL server using Perl DBI module, I have tried all the connection string format still Perl is throwing invalid connection string error.
I have already tried code snippet available on perl monk website.
#!/usr/bin/perl -w
use strict;
use DBI;
# Set up variables for the connection
my $server_name = '00.120.124.1;3181';
my $database_name = 'abcd';
my $database_user = 'kkkk';
my $database_pass = 'password';
my $DSN = 'driver={SQL Server};server=$server_name;da
+tabase=$database_name;uid=$database_user;pwd=$database_pass;';
my $dbh = DBI->connect("DBI:ODBC:$DSN") || die "Couldn't open database
+: $DBI::errstr\n";
Expected result is to connect to Database.
failed: [Microsoft][ODBC SQL Server Driver][DBNETLIB]SQL Server does not exist or access denied. [Microsoft][ODBC SQL Server Driver][DBNETLIB]ConnectionOpen (Connect()). (SQL-01000) [state was 01000 now 01S00] [Microsoft][ODBC SQL Server Driver]Invalid connection string attribute (SQL-01S00) at perl.pl line 16. Couldn't open database +: [Microsoft][ODBC SQL Server Driver][DBNETLIB]SQL Server does not exist or access denied. (SQL-08001) [state was 08001 now 01000] Invalid connection string attribute (SQL-01S00)
The lines of your post that begin with +
+tabase=$database_name;uid=$database_user;pwd=$database_pass;';
+: $DBI::errstr\n";
were incorrectly copied and pasted from perlmonks.org. The leading + sign is a convention that indicates a long line was split. You should delete the + and join the line to the previous line, so that your code will read
my $DSN = 'driver={SQL Server};server=$server_name;database=$database_name;uid=$database_user;pwd=$database_pass;';
my $dbh = DBI->connect("DBI:ODBC:$DSN") || die "Couldn't open database: $DBI::errstr\n";
Your error message contains the following:
SQL Server does not exist or access denied
Your set-up code contains the following:
my $server_name = '00.120.124.1;3181';
'00.120.124.1;3181' is not a valid server name or IP address. You should correct the IP address section (it can't start with '00') and remove the port into a separate parameter.
You also have the username and password as part of your DSN. I don't know if DBD::ODBC supports that usage (it's not mentioned in the documentation) but it's more traditional to have those as separate parameters to the connect() call.
All in all, I think you want something more like this:
my $server_name = '00.120.124.1'; # But this needs to be corrected
my $server_port = 3181;
my $database_name = 'abcd';
my $database_user = 'kkkk';
my $database_pass = 'password';
my $DSN = "driver={SQL Server};server=$server_name;port=$server_port;database=$database_name";
my $dbh = DBI->connect("DBI:ODBC:$DSN", $database_user, $database_pass)
|| die "Couldn't open database: $DBI::errstr\n";
Also note that I've changed the quote characters used to create your $DSN variable from single quotes to double quotes. Variables are not expanded in signel quotes, so you weren't getting the values of $server_name, etc. in your DSN.
The better way to connect is with the DBD::Sybase module. The name wouldn't suggest it but SQL Server takes its lineage from Sybase. That way you can avoid ODBC. http://metacpan.org/pod/DBD::Sybase#Using-DBD::Sybase-with-MS-SQL

Special character (!, exclamation mark) in DB2 user password gives error when starting i2 Analyze or connecting from DB2 command console

The following error occurs when starting i2 Analyze with example deployment
(some parts of error messages are in Finnish because of the Windows localization settings, sorry about that)
setup -t startLiberty
java.sql.SQLInvalidAuthorizationSpecException: [jcc][t4][2013][11249][4.17.29] On ilmennyt yhteyden käyttöoikeusvirhe. Syy: Käyttäjätunnus tai tunnussana ei kelpaa. ERRORCODE=-4214, SQLSTATE=28000 DSRA0010E: SQL State = 28000, Error Code = -4 214
I believe the error is more closely related to DB2(10.5 FP7) & Windows(W12R2) than i2 Analyze itself because when connecting from DB2 command console (db2cmd) and giving both username and password (with !) within a single line:
connect to WRITESTORE user db2admin using <SomePasswordWith!>
The error shown in console is as follows:
SQL0104N Järjestelmä on löytänyt merkkijonoa "<tunnus>" seuraavan
tunnistamattoman sanakkeen "!". Odotettuja sanakkeita ovat esimerkiksi
seuraavat: "NEW". SQLSTATE=42601
Anyhow, if password (with character !) is given only when prompted eg:
connect to WRITESTORE user db2admin
and giving password when asked, user is logged in without an error.
Also when connecting to DB2 with IBM DataStudio gives no error.
So, using passwords without special characters is a workaround for the issue.
http://www-01.ibm.com/support/docview.wss?uid=swg21303153
Username/password with special characters need to be quoted when using them through CLP within db2prompt
Lainausmerkkeihin :)
connect to WRITESTORE user db2admin using '<SomePasswordWith!>'

Check if Windows user exists in SQL Server using Powershell. Remove Sa rights if so

I'm looking to check if a user exists in SQL Server using PowerShell and remove their sa rights if they do. So far I have
clear
sqlps
cd "sql\$env:COMPUTERNAME\default"
Invoke-Sqlcmd -Query {if exists (select name from sys.database_principals where name='Builtin\Administrators') ALTER SERVER ROLE [sysadmin] DROP MEMBER [Builtin\Administrators]
else
print 'Account Does not exist or SA has already been removed from account' } #Runs a query on SQL Server to remove the SA privilege from Builtin\Administrators
exit
For some reason it chokes when I try to run this. It complains of the following error:
Missing '(' after 'if' in if statement.
At line:4 char:26
Missing closing ')' after expression in 'if' statement.
At line:5 char:1
Missing statement block after if ( condition ).
At line:5 char:1
Missing statement block after 'else' keyword.
At line:6 char:1
Passing the whole query as a string with single quotes
clear
sqlps
cd "sql\$env:COMPUTERNAME\default"
Invoke-Sqlcmd -Query 'if exists (select name from sys.database_principals where name='Builtin\Administrators') ALTER SERVER ROLE [sysadmin] DROP MEMBER [Builtin\Administrators]
else
print 'Account Does not exist or SA has already been removed from account';' #Runs a query on SQL Server to remove the SA privilege from Builtin\Administrators
exit
gives me a different error at least.
Invoke-Sqlcmd : A positional parameter cannot be found that accepts argument 'Builtin\Administrators) ALTER SERVER ROLE [sysadmin] DROP MEMBER [Builtin\Administrators]
else
print Account'.
At line:4 char:14
+ Invoke-Sqlcmd <<<< -Query 'if exists (select name from sys.database_principals where name='Builtin\Administrators') ALTER SERVER ROLE [sysadmin] DROP MEMBER [Builtin\Administrators]
+ CategoryInfo : InvalidArgument: (:) [Invoke-Sqlcmd], ParameterBindingException
+ FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.SqlServer.Management.PowerShell.GetScriptCommand
The -Query parameter for invoke-sqlcmd is a string. You passed a scriptblock.
That should get you moving in the right direction.
Also, #Remus is right...including the error message will get you better help.
Edit: Now that you're using a string parameter, you should probably use double-quotes around the query since you have single quotes embedded in it.