I am using nodes mssql module in order to connect to mssql database. However my password contains # and the pattern to the connection is
mssql://username:password#localhost/database
It throws connection error. I assume it is because it sees # so content after it it takes as localhost and so on.
Is there a way how to connect there with password that contains #?
Thanks
From MSDN:
certain symbols must be enclosed by double quotation marks (") or square brackets ([ ]).
Use these delimiters in Transact-SQL statements when the SQL Server login, user, role, or password has the following characteristics:
1.Contains or starts with a space character.
2. Starts with the $ or # character.
Related
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"')
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
Ive migrated from Access to SQL Server 2012 but when I link my table back into the Access db I have some field names that are 64characters long, which becuase they have spaces and other special characters in them encloses them in square brackets e.g. [this field]. However the square brackets are included in the character count when creating the linked table into Access it truncates the last 2 characters off the field name e.g. [this fie].
Anyone got a way around this to ensure all 64 characters are shown in the table?
tia
M
When I use the following to check if the DB exists using PowerShell throws an error.
Test-Path SQLSERVER:\SQL\TestServer\TestData\Databases\Data\Site1.Test.User.Com
ErrorMessage:
Test-Path : Cannot retrieve the dynamic parameters for the cmdlet. SQL Server PowerShell provider error: The number of keys specified does not match the number of keys required to address this object. The number of keys required are: Name.
Use quotes:
Test-Path "SQLSERVER:\SQL\TestServer\TestData\Databases\\Data\Site1.Test.User.Com"
or
Test-Path 'SQLSERVER:\SQL\TestServer\TestData\Databases\\Data\Site1.Test.User.Com'
Edit
The issue is escaping the periods, as the SQL Server PowerShell provider does not like them. Normally, I would expect weird characters within single quotes to be escaped.
Unfortunately I can't try this on my machine. Here are a few other escape method to try - please let me know if one of these works for you:
# I expect the regular PowerShell escape character to work
"SQLSERVER:\SQL\TestServer\TestData\Databases\Data\Site1`.Test`.User`.Com"
# If not, standard SQL syntax
"SQLSERVER:\SQL\TestServer\TestData\Databases\Data\[Site1.Test.User.Com]"
# Hexadecimal periods
"SQLSERVER:\SQL\TestServer\TestData\Databases\Data\Site1%2eTest%2eUser%2eCom"
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"