GRANT on db with a separator in name not working - database

I have a problem on my Debian server with MariaDB on it.
I'm trying to grant all privileges to a user ('agricoop') on my database called extranet-agricoop.
I'm writing : GRANT ALL PRIVILEGES ON extranet-agricoop.* TO 'agricoop'#'localhost';
I get the error message : "You have an error in your SQL syntax [...] near 'extranet-agricoop.* TO 'agricoop'#'localhost'' at line 1"
It worked for my other users on other table but just not for that one. If I select ‘*.*´ it works so for me the problem seems to come from the name of the db. I've tried to escape the separator but still not working.
Have you got any idea ?
Thanks :)

Identifiers have to be quoted if it contains one or more character which is not part of [a-z,A-Z,0-9,$,_] (or isn't a unicode character > 0x0080).
If sql_mode ANSI_QUOTES is set, you have to use double quotes ("), if sql_mode is MSSQL square brackets([..]) have to be used.
Example:
GRANT ALL ON `better-use-dash-than-minus`.* TO foo#localhost

Related

Can I use a domain account in OPENDATASOURCE()

I have been trying and failing to use a domain account in SQL Server's OPENDATASOURCE().
I've tried many variations, including the following:
OPENDATASOURCE ('SQLNCLI', 'Data Source=<server name>; User ID=<domain>\<user>; Password=<password>' )
I've also tried escaping the backslash like this:
OPENDATASOURCE ('SQLNCLI', 'Data Source=<server name>; User ID=<domain>\\<user>; Password=<password>' )
I get following error message in the first case:
Msg 18456, Level 14, State 1, Line 1
Login failed for user '<domain>\<user>'
In the second case, I get the same except that I see both backslashes in the error message.
Is what I'm trying to do possible?
Also, the password includes a backtick (`) character. Is that forbidden in OPENDATASOURCE?
No OleDb drivers support using Windows Auth with provided username/password. The only way to use Windows Auth is by impersonating the user, injecting the user's credentials in the Windows Credential Store, or using runas /netonly.
EDIT: To use a backtick or special char in the password you need to encapsulate in double quotes
For example, if your password is "`password", you may need to enter like:
OPENDATASOURCE('SQLNCLI', 'Data Source=server_name;uid=domain\username;pwd="`password"')

Replace is not working for weird character

I use UPDATE a SET GR_P = REPLACE(GR_P,'','') FROM mytable a to replace things.
But replace function is not working for below charter:
In Query analyzer it works but when I used SSIS Execute SQL task or OLEDB Source then it is giving me error:
No Connection manager is specified.
In Toad against Oracle (since that's one of your tags), I issued this (pressing ALT-12 to get the female symbol) and got 191 as a result. note selecting it back using CHR(191) shows an upside-down question mark though.
select ascii('♀') from dual;
Given that, this worked but it's Oracle syntax, your mileage may vary.
UPDATE mytable SET GR_P = REPLACE(GR_P, CHR(191));
Note if it does not work, that symbol could be for another control character. You may need to use a regular expression to eliminate all characters not in a-zA-Z0-9, etc. I suspect you'll need to update your tags to get a more accurate answer.
Maybe this info will help anyway. Please post back what you find out.

How can I copy/upsize a table from access 2013 to sql server using vba

I am currently working on a project where is need to send existing tables with all their fields to an sql database (backend).
what i have so far is to generate an make-table query and then execute it, but i allways get the error....
"SELECT statement includes a reserved word or an argument name that is
misspelled or missing, or the punctuation is incorrect."
the generated string is SELECT * INTO (Provider=SQLOLEDB;SERVER=stserver;DATABASE=stdatabase;UID=userid;PWD=userpass).AAAANewTable FROM AAAANewTable WITH OWNERACCESS OPTION;
of cause the stdatabase and userid ect, are string variables :-)
Can anyone help me with the correct syntax? or give an example of what the correct syntax should look like?
Any help would be greately appreciated.

Creating Linked SQL Server - server name has comma

I am trying to set up a linked server connection to a SQL Server that is specifying the port at the end, like this:
[My-Server-PROD-01,5983]
However, it kicks back an error saying the dash is invalid. The server name is surrounded by braces like it is supposed to so I think it is the comma in the server name. Can someone tell me how to get that to work? Do I need to do some escaping of the comma? Surround it by quotes or braces?
#jthalliens - "what about using the IP address from [My-Server-PROD-01,5983] in order to avoid conflicts"

Oracle create db link using a proxy schema

So I want to create a database link in oracle, my username is jefferson and I want to connect trough opms so I was told to do this.
create database link tmpp connect to jefferson[opms] identified by nothing using $something ;
For some reason when I try to use [] syntax it just tells me indentified is missing. Why is this not working, I was told to do it this way but I can't find any help in the official documentation for [] usage or the correct syntax.
You can create a fixed-user database link like this, but you need to enclose the entire proxy user identifier in double-quotes; and because it's now a quoted identifier the case has to match the DBA_USERS username, which is uppercase by default:
create database link tmpp connect to "JEFFERSON[OPMS]" identified by nothing using ... ;
As noted in MOS document 1477939.1 you can't create a connected-user database link (which you aren't trying to do); and the 30-character limit on identifiers applies, so the total length of both usernames plus the square brackets has to be 30 characters or less (which is also fine in your example).
However, as discussed in this related question, this functionality is currently broken in 11.2.0.4 and above because of bug 19191702.

Resources