Using Testcontainers, how can I set the database collation when starting a docker image for a MS SQL Server database?
On the container, you should just add an environment variable.
String dockerImageName = // here the specific imahe + tag
String collation = // a valid collation, e.g. "Latin1_General_CS_AS"
MSSQLServerContainer mssqlServerContainer = new MSSQLServerContainer(dockerImageName);
mssqlServerContainer.addEnv("MSSQL_COLLATION", collation);
Related
Working with SQL Server 2019 Enterprise CU18 Polybase (On-premise). I have a working connection from SQL Server to Oracle that is defined as follows:
CREATE EXTERNAL DATA SOURCE [OracleDataSource]
WITH (LOCATION = 'oracle://ExaData1:1521', CREDENTIAL = [OracleCredential])
However, we have an HA/DR pair for our exadata system. ExaData1 and ExaData2. If we did this in a linked server, the connetion would look like this:
(DESCRIPTION=(ENABLE=BROKEN)(ADDRESS_LIST=(LOAD_BALANCE=YES)(FAILOVER=YES)(ADDRESS=(PROTOCOL=tcp)(HOST=ExaData1.domain.com)(PORT=1521))(ADDRESS=(PROTOCOL=tcp)(HOST=ExaData2.domain.com)(PORT=1521)))(CONNECT_DATA=(SERVICE_NAME=OracleTNSName)))
Yet, I can't seems to define it this way in Polybase (at least I haven't figure out how to yet). I need to figure out how to list both possible servers in the External Data Source so when the DB fails over, it will follow it naturally.
The other option is to figure out how to use the TNS Name, rather than the server name for the Location, but I've not figured that out either. Currently, when I define a table, it looks like this, which is based upon the previously defined data source, listing the TNS name as part of the DATA_SOURCE properties:
CREATE EXTERNAL TABLE [Polybase].[sample]
(
[SID] [nvarchar](8) NULL,
[MESSAGE_DATE] [datetime2](7) NULL,
[MESSAGE_ID] [nvarchar](3) NULL
)
WITH (DATA_SOURCE = [OracleDataSource],LOCATION = N'[OracleTNSNAME.domain.com].OracleSchema.SAMPLE')
Anyone have suggestions or options as I'm not finding anything in the MS documenation.
Appreciate any and all support.
Have you tried with this?
oracle//server1:1521; AlternateServers=(server2:1521,server3:1521,server4:1521); LoadBalancing=true
The only other option to connect is by using ExaData SCAN name (configured by Oracle database administrator, which resolves to any of the nodes using a single name). From Oracle it looks like this:
(DESCRIPTION =
(CONNECT_TIMEOUT=90) (RETRY_COUNT=20)(RETRY_DELAY=3) (TRANSPORT_CONNECT_TIMEOUT=3)
( ADDRESS = (PROTOCOL = TCP)(HOST=sales-scan.mycluster.example.com)(PORT=1521))
(CONNECT_DATA=(SERVICE_NAME=oltp.example.com)))
Then from SQL Server you connect to sales-scan.mycluster.example.com
Oracle version 12.1.0.2
max_string_size=extended
I am using sql server ODBC to connect to sql server database via Oracle gateway to sql server, the connection is working fine and i am able to access sql server tables.
However, as per Oracle documentation starting 12c and with extended limit on varchar2 data type the conversion of sqlserver varchar(max) to oracle Long will only happen if the length of sql server data is more than 32k.
My sql server table has few columns defined as varchar(max) in and all of those i see getting converted to LONG when i try to describe the table over dblink.
I need to load the data from sql server to oracle and the above problem is making it very difficult as more than one long columns can not be copied over dblink.
Any help will be deeply appreciated.
I created a view on the SQL server side that uses substr(column,1,4000) to fit within the old Oracle max 4000 character length. This worked quite well with Oracle 11.
I am in the process of migrating to a new Oracle 18 instance that uses character set AL32UTF8 instead of WE8MSWIN1252. The exact same SQL is now getting:
ORA-28500: connection from ORACLE to a non-Oracle system returned this message:
[Microsoft][ODBC Driver Manager] Program type out of range {HY003}
ORA-02063: preceding 2 lines from CEAV195
Fortunately I don't have a tight deadline for working this out.
Comment: I am now getting
[Error] Execution (8: 17): ORA-00997: illegal use of LONG datatype
despite using the following in the view on the SQL Server side:
cast(substring(cr.response,1,2000) as varchar(2000)) response
As I said earlier, this worked perfectly fine with Oracle 11 and the WE8MSWIN1252 character set.
I hit the same issue and found this solution elsewhere
set serverout on
DECLARE
l_cursor BINARY_INTEGER;
l_id VARCHAR2(60);
l_temp VARCHAR2(250);
l_notes VARCHAR2(32767);
BEGIN
l_cursor := DBMS_HS_PASSTHROUGH.open_cursor#remotedb;
DBMS_HS_PASSTHROUGH.parse#remotedb(
l_cursor,
'select "RecId","Notes" from "MySqlServerTable"'
);
LOOP
DBMS_HS_PASSTHROUGH.get_value#remotedb(l_cursor, 1, l_id);
DBMS_HS_PASSTHROUGH.get_value#remotedb(l_cursor, 2, l_notes);
DBMS_OUTPUT.put_line(l_id || ' ' || l_notes);
END LOOP;
exception
when others then
DBMS_HS_PASSTHROUGH.close_cursor#remotedb(l_cursor);
raise;
END;
/
I have been trying to call a SQL Server stored procedure that has no parameters and no return values. All it does is recalculate data in a SQL Server database.
I thought I could use something simple like
lsqlcmd = " execute storedprocname"
but the procedure is not being called and I am not receiving an errors.
Any suggestions?
Can you try calling it in SQLEXEC()? This how I've seen it done:
TEXT TO lcSQLCommand
<database>.<schema>.<sproc>
ENDTEXT
gcConnectionString = [Driver={SQL Server Native Client 10.0};Server=] + "<servername>" + [;Database=] + "<database>" + [;Trusted_Connection=yes]
STORE SQLSTRINGCONNECT(gcConnectionString) TO gnConnHandle
SQLEXEC(gnConnHandle, lcSQLCommand)
You'll need to update the connection string to however your database is configured, this was for windows authentication.
Using Delphi 7 with ADO objects, is it possible to determine the ODBC database driver from the TADOConnection object? So detect whether it is MS-Access or SQL Server or Oracle etc.
The program connects to a database by just using the name of an ODBC data source, and I want to determine whether that database is an MS-Access database or SQL Server. I want to do this because MS-Access and SQL Server use different SQL function names to cast an integer to a string.
The application builds an SQL string which retrieves the VERSION of some configuration objects. It works for SQL server using cast(), but I also want to support MS-Access which uses CStr():
SELECT NAME + '_' + CAST(VERSION as varchar) as OBJECT_NAME FROM ANALYSIS // SQL Server
SELECT NAME + '_' + CStr(VERSION) as OBJECT_NAME FROM ANALYSIS // MS-Access
I've tried looking at the TADOConnection.Provider but that is MSDASQL.1 in both cases.
if (myqry.Connection.Provider = 'MSDASQL.1') then
strSQL := strSQL + 'cast(' + myfieldname + ' as varchar)' // always goes here..
else
strSQL := strSQL + 'CStr(' + myfieldname + ')'; // ..never to here
I've looked at all the TADOConnection properties, but I'm starting to suspect it's not possible. Any ideas how to solve this?
ODBC is designed to abstract away the implementation details of the server. You can use ODBC specific syntax that will be translated to a statement of the appropriate SQL flavour for the server. Here you can substitute :
... { fn CONVERT( VERSION, SQL_VARCHAR ) } AS OBJECT_NAME FROM ANALYSIS
These substitutions are known as ODBC Escape Sequences and can be substituted in queries where there are vendor-specific syntax differences.
I am trying to update a row in the my SQL Server 2008 R2 database.
The value of the particular column is of type String.
The current values in my database is of the form: NMA.
But it should be N'MA.
My query is:
UPDATE mymodifiedtable
SET FirstName = 'N'MA'
WHERE receiptNo = '45047603'
This is not working for me after googling it.
Pls advice.
I would also like a link where I can learn more on this type of escape characters in SQL Server.
You can use the quote character to escape quotes. Try SET FirstName = 'N''MA'