SAS Access/Interface with SQL server - sql-server

I am having a problem with connecting to data in SQL database.
I am not sure if I don't have the certain driver or if the code I am using is incorrect. Could someone please help guide me in the right direction?
Below is the product license that I have after running Proc Setinit
Operating System: WX64_WKS.
Product expiration dates:
---Base SAS Software
14FEB2018
---SAS/STAT
14FEB2018
---SAS/GRAPH
14FEB2018
---SAS/Secure 168-bit
14FEB2018
---SAS/Secure Windows
14FEB2018
---SAS Enterprise Guide
14FEB2018
---SAS/ACCESS Interface to PC Files
14FEB2018
---SAS/ACCESS Interface to Microsoft SQL Server
31DEC2017
---SAS Workspace Server for Local Access
14FEB2018
---SAS/ACCESS to Amazon Redshift
31DEC2017
---High Performance Suite
14FEB2018
Below is product installed after I ran Proc Product_Status
16 proc Product_Status ; run;
For Base SAS Software ...
Custom version information: 9.4_M5
Image version information: 9.04.01M5P090617
For SAS/STAT ...
Custom version information: 14.3
For SAS/GRAPH ...
Custom version information: 9.4_M5
For SAS/ACCESS to Amazon Redshift ...
Custom version information: 9.42
For High Performance Suite ...
Custom version information: 2.2_M6
For SAS/ACCESS Interface to PC Files ...
Custom version information: 9.4_M5
NOTE: PROCEDURE PRODUCT_STATUS used (Total process time):
real time 0.24 seconds
It seems like sas access to SQL server is not installed right?
I am also trying these codes to connect and all got the error. Which direction of code should I be using? ODBC or sqlsvr?
I tried sqlsvr and got this error message
Code:
LIBNAME database1 sqlsvr user=datareader password=myspassword DATAsrc=clientA;
Error:
LIBNAME database1 sqlsvr user=datareader password=XXXXXXX
DATAsrc=clientA;
ERROR: CLI error trying to establish connection: [Microsoft][ODBC
Driver Manager] Data source name not found and no default driver
specified ERROR: Error in the LIBNAME statement.
When I tried ODBC route, I got this message
Code:
LIBNAME database1 ODBC DSN=clientA User=datareader Password=myspassword ;
Error:
LIBNAME database1 ODBC DSN=clientA User=datareader Password=XXXXXXX;
ERROR: The ODBC engine cannot be found. ERROR: Error in the LIBNAME
statement.
Could someone please point me in the right direction? Should DSN be the name of the database of each client as "ClientA" etc or should it be the name of the server?
Thank you so much!

The SQLSRV library engine DATASRC= option should specify an entry shown in the "ODBC Data Source Administrator (64-bit)" application. You can add an entry, set (configure) the connection parameters and test the connection. Suppose you name your new DSN Sales History, the libname might be
libname OldSales sqlsrv datasrc="Sales History" user=... pass=...;
For the case of wanting to specify the server name, schema, port, connection persistence, etcetera directly in your SAS code you would use the NOPROMPT= option. The option value will be a semi-colon separated list of name=value pairs:
libname OldSales sqlsrv user=... pass=... noprompt="Server=<url or hostname><\instance-name-if-other-than-default>,<port-number-if-other-than-default>;Initial Catalog=<database-to-use-if-other-than-default>;..other connection parameters..";
Microsoft documentation "Using Connection String Keywords with SQL Server Native Client" is a great reference. Another good resource for examples is connectionstrings website. A NOPROMPT= value that seems correct, yet is not to working, may have or require unusual spacing or quoting.
For a small group of coders in a static data hosting environment the NOPROMPT= method will probably be OK and require no extra support (other than access) in a large organization. If the data hosting migrates or changes your SAS code will have to be changed.
In a larger context, especially in a SAS Server environment, you are best off having your IT support to create the DSNs that your SAS sessions will need. The DSNs will be the single gateway that all programs and users will use and coders and analysts will not have to get bogged down in the connection details.

Related

Sage 300 CRE Timberline Data ODBC Driver DELETE Error

I am trying to automate archiving of the Log files generated by sage. We generate an average of 15,000 log entries a day and the LogViewer in sage is so slow it is nearly unusable after a month. I am querying the data older than seven days and then inserting it to our SQL Server. Using the same connection string I can query data from the QLM Master Log but when I go to delete data I get an error.
With my Sage user service account:
ERROR [42000] [Simba][SimbaEngine ODBC Driver][DRM File Library]Access denied.
With my personal Sage user account. I was failing at opening second connection with this error: (Still not sure why but not directly relevent)
ERROR [08001] [Simba][SimbaEngine ODBC Driver][DRM File Library]Invalid account name.
ERROR [IM006] [Microsoft][ODBC Driver Manager] Driver's SQLSetConnectAttr failed
ERROR [01000] [Microsoft][ODBC Driver Manager] The driver doesn't support the version of ODBC behavior that the application requested (see SQLSetEnvAttr).
Once i adjusted my code to no longer attempt a second connection open I get the same error:
ERROR [42000] [Samba][SimbaEngine ODBC Driver][DRM File Library]Access denied.
Any help would be appreciated but I am looking for.
Is this actually a permissions issue?
Is the problem with my Windows User account OR Sage user account?
What access is required to run the delete command?
After speaking with a Sage 300 CRE Certified Consultant I have been informed that data in Log Viewer is not editable via ODBC, and to remove data I have to use the Log Viewer interface. According to the consultant Sage has an open DLL that would provide the functionality but it would open other areas of the program as well and they do not give it out normally.
Though it runs somewhat counter to jrummell's comments this is what I was told; the expert has spoken the project is officially at a dead end pending the acquisition of this open DLL.
I will let the community know if any additional information pertaining to this question is uncovered.

Error when trying to install sonarqube on SQL Server 2008

When I try to install sonarqube database I get some errors and database is not created
ActiveRecord::JDBCError: The driver encountered an unknown error: unable to choose type for timestamp from:
["datetime2", "datetime"]
initialize at C:/sonarqube/web/WEB-INF/gems/gems/activerecord-jdbc-adapter-1.1.3/lib/arjdbc/jdbc/connection.rb:66
initialize at C:/sonarqube/web/WEB-INF/gems/gems/activerecord-jdbc-adapter-1.1.3/lib/arjdbc/jdbc/adapter.rb:31
jdbc_connection at C:/sonarqube/web/WEB-INF/gems/gems/activerecord-jdbc-adapter-1.1.3/lib/arjdbc/jdbc/connection_methods.rb:6
send at org/jruby/RubyKernel.java:2227
new_connection at C:/sonarqube/web/WEB-INF/gems/gems/activerecord-2.3.15/lib/active_record/connection_adapters/abstract/connection_pool.rb:223
checkout_new_connection at C:/sonarqube/web/WEB-INF/gems/gems/activerecord-2.3.15/lib/active_record/connection_adapters/abstract/connection_pool.rb:245
checkout at C:/sonarqube/web/WEB-INF/gems/gems/activerecord-2.3.15/lib/active_record/connection_adapters/abstract/connection_pool.rb:188
loop at org/jruby/RubyKernel.java:1519
checkout at C:/sonarqube/web/WEB-INF/gems/gems/activerecord-2.3.15/lib/active_record/connection_adapters/abstract/connection_pool.rb:184
mon_synchronize at jar:file:/C:/sonarqube/web/WEB-INF/lib/jruby-complete-1.7.9.jar!/META-INF/jruby.home/lib/ruby/1.8/monitor.rb:191
checkout at C:/sonarqube/web/WEB-INF/gems/gems/activerecord-2.3.15/lib/active_record/connection_adapters/abstract/connection_pool.rb:183
connection at C:/sonarqube/web/WEB-INF/gems/gems/activerecord-2.3.15/lib/active_record/connection_adapters/abstract/connection_pool.rb:98
retrieve_connection at C:/sonarqube/web/WEB-INF/gems/gems/activerecord-2.3.15/lib/active_record/connection_adapters/abstract/connection_pool.rb:326
retrieve_connection at C:/sonarqube/web/WEB-INF/gems/gems/activerecord-2.3.15/lib/active_record/connection_adapters/abstract/connection_specification.rb:123
connection at C:/sonarqube/web/WEB-INF/gems/gems/activerecord-2.3.15/lib/active_record/connection_adapters/abstract/connection_specification.rb:115
initialize at C:/sonarqube/web/WEB-INF/gems/gems/activerecord-2.3.15/lib/active_record/migration.rb:440
up at C:/sonarqube/web/WEB-INF/gems/gems/activerecord-2.3.15/lib/active_record/migration.rb:401
migrate at C:/sonarqube/web/WEB-INF/gems/gems/activerecord-2.3.15/lib/active_record/migration.rb:383
upgrade_and_start at C:/sonarqube/web/WEB-INF/config/../lib/database_version.rb:62
automatic_setup at C:/sonarqube/web/WEB-INF/config/../lib/database_version.rb:74
(root) at C:/sonarqube/web/WEB-INF/config/environment.rb:239
load at org/jruby/RubyKernel.java:1094
(root) at file:/C:/sonarqube/web/WEB-INF/lib/jruby-rack-1.1.13.2.jar!/jruby/rack/rails/environment2.rb:1
load_environment at file:/C:/sonarqube/web/WEB-INF/lib/jruby-rack-1.1.13.2.jar!/jruby/rack/rails/environment2.rb:25
load_environment at file:/C:/sonarqube/web/WEB-INF/lib/jruby-rack-1.1.13.2.jar!/jruby/rack/rails_booter.rb:79
i was reading about and looks like database driver is not working alright
Any clues about how can i get this working on SQL Server?
There might be a problem with the locale settings of the database. In my case it helped to set the language for the sonarqube database user to "English". See here.
After a few tries, I changed the SQL driver (sqljdbc4.jar) to one directly from Microsoft, it looks like my previous driver was third party modified.
http://www.microsoft.com/en-us/download/confirmation.aspx?id=21599 this is the original mssql driver form jdbc.
http://www.sezok.de/sonar/sonar.html this guide was helpful too.
after changing driver, everything works OK

Eclipse JPA tools fails to load schema metadata for SQL Server

I am trying to use JPA with SQL Server. Eclipse has great tools to map entities from database and vice-versa. For this to work, I need to associate a connection to a JPA project.
So I created a database (named it "rowcount") and a table on this database. Then when I go to Eclipse, open the JPA perspective, log in the database (Datasource Explorer / Database Connections), I cannot see any Schema associated to this particular database.
Looking in the "Error Log" view of Eclipse, I've got the following error everytime I click on "Schemas" tree-view item on Eclipse:
eclipse.buildId=M20130204-1200
java.version=1.7.0_15
java.vendor=Oracle Corporation
BootLoader constants: OS=win32, ARCH=x86_64, WS=win32, NL=pt_BR
Framework arguments: -product org.eclipse.epp.package.jee.product
Command-line arguments: -os win32 -ws win32 -arch x86_64 -product org.eclipse.epp.package.jee.product
Error
Tue May 21 10:34:42 BRT 2013
com.microsoft.sqlserver.jdbc.SQLServerException
com.microsoft.sqlserver.jdbc.SQLServerException: Incorrect syntax near the keyword 'rowcount'.
at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDatabaseError(SQLServerException.java:216)
at com.microsoft.sqlserver.jdbc.SQLServerStatement.getNextResult(SQLServerStatement.java:1515)
at com.microsoft.sqlserver.jdbc.SQLServerStatement.doExecuteStatement(SQLServerStatement.java:792)
at com.microsoft.sqlserver.jdbc.SQLServerStatement$StmtExecCmd.doExecute(SQLServerStatement.java:689)
at com.microsoft.sqlserver.jdbc.TDSCommand.execute(IOBuffer.java:5696)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.executeCommand(SQLServerConnection.java:1715)
at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeCommand(SQLServerStatement.java:180)
at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeStatement(SQLServerStatement.java:155)
at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeQuery(SQLServerStatement.java:616)
at org.eclipse.datatools.connectivity.sqm.internal.core.connection.StatementAdapter.executeQuery(StatementAdapter.java:73)
at org.eclipse.datatools.enablement.msft.internal.sqlserver.loaders.SQL2005SchemaLoader.createResultSet(SQL2005SchemaLoader.java:53)
at org.eclipse.datatools.connectivity.sqm.loader.JDBCSchemaLoader.loadSchemas(JDBCSchemaLoader.java:111)
at org.eclipse.datatools.connectivity.sqm.core.rte.jdbc.JDBCCatalog.loadSchemas(JDBCCatalog.java:101)
at org.eclipse.datatools.connectivity.sqm.core.rte.jdbc.JDBCCatalog.getSchemas(JDBCCatalog.java:64)
at org.eclipse.datatools.connectivity.sqm.server.internal.ui.explorer.providers.content.layout.vnode.ServerExplorerVNodeContentProviderNav.displaySchemaNodeChildren(ServerExplorerVNodeContentProviderNav.java:126)
at org.eclipse.datatools.connectivity.sqm.server.internal.ui.explorer.providers.content.layout.AbstractOnDemandContentProviderNav.getChildren(AbstractOnDemandContentProviderNav.java:169)
at org.eclipse.datatools.connectivity.sqm.server.internal.ui.explorer.providers.content.layout.AbstractOnDemandContentProviderNav.getChildren(AbstractOnDemandContentProviderNav.java:243)
at org.eclipse.datatools.connectivity.sqm.server.internal.ui.explorer.providers.content.layout.AbstractLayoutProviderNav.getChildren(AbstractLayoutProviderNav.java:85)
at org.eclipse.datatools.connectivity.sqm.server.internal.ui.explorer.providers.content.impl.ServerExplorerContentProviderNav.load(ServerExplorerContentProviderNav.java:153)
at org.eclipse.datatools.connectivity.sqm.server.internal.ui.explorer.loading.LoadingJob.run(LoadingJob.java:43)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:53)
I am using the latest sqljdbc4.jar and "Microsoft SQL Server 2008 JDBC Driver" in the JPA Driver properties.
This error prevents me to deploy the application in an EAR file. Even if I manage to deploy it manually on Weblogic, the application fails for the following reason:
openjpa-1.1.1-SNAPSHOT-r422266:957329 nonfatal user error> org.apache.openjpa.persistence.ArgumentException: An error occurred while parsing the query filter "SELECT N FROM Note N". Error message: The name "Note" is not a recognized entity or identifier. Known entity names: []
Oddly, "master" database shows some of its objects and schemas. Is there a workaround in SQL Server, in the JDBC driver or Eclipse for this?
Shame on me. The problem was caused because the database name was a reserved word for SQL Server. After I renamed it, it worked fine.
See the comments above, on the question.
My sincere apologies to all who stumbled here while being stressed by real problems.

Connect to IBM i server from Sql Server 2008 R2

I have a big deal: I have to connect (I just want to read data, not to write) to my customer's IBM AS/400 (aka iSeries, now IBM i) server...
I think I have all parameters needed (given me by the AS/400 programmer), but I can't figure out which driver I have to use, and if I have all software needed to to this!
I've installed IBM AS/400 ClientAccess 5.8 driver (with a patch for latest OS), and now I'm trying to configure a new Linked Server in my Sql Server 2008 R2 (x64) server.
First problem: Which driver should I use?
I have so many choices (but maybe none of these works!!):
IBM DB2 UDB for iSeries IBMDASQL OLE DB Provider
IBM DB2 UDB for iSeries IBMDA400 OLE DB Provider
IBM DB2 UDB for iSeries IBMDARLA OLE DB Provider
...or maybe other generic OLEDB/ODBC drivers?!
Second problem: Where should I put my parameters (in which fields I mean!)
In any case, in I choose a provider for my Linked Server, obviously I have to set my parameters...but I only have this:
Username of an ADMIN user
Password of the ADMIN user
AS/400 server IP address
The name of "main" archive, in which my data are stored (something like ACG_DATV2)
Third problem: How should I write my queries? How to reference an AS/400 "archive" and tables?
I don't know how to build my reading query: where are tables and views (?!) stored and how can I reference them?
Thank you in advance!
I think there are many ways to achieve what you want, but I'll try to explain what I would do in your case.
With that version of IBM ClientAccess (and also the patch), I should not have troubles in getting connected with a Sql Server 2008 R2 Linked Server if you use the correct data provider.
First of all, try to configure your linked server in this way:
Linked server name: what you want, it's just a custom name (example: MYAS400)
Provider: IBM DB2 UDB for iSeries IBMDASQL OLE DB Provider
Product name: not important, something like iSeries Access OLEDB Driver
Data source: AS/400 server IP address (example: 192.168.0.1)
Either if you configure the Linked Server using the wizard or by SQL code, the first time it will need to access the data of the AS/400 server, you'll be asked for credentials, with a typical iSeries window (look at my example).
Set your username (User ID) and the relative password, without regarding the case of the strings!!
As a general tip (but this is only related to my experience!), try to avoid special characters and upper/lower cases distinctions...
If you arrive here (no problems in the Linked Server creation), the Linked Server should work (so the first and the second problem are solved): let's build the first query!
Once the Linked Server is created, all you need is just to correctly reference the archive, the library and, of course, the correct table and the Linked Server (by name): with this informations, build a query like this (it's the usual T-SQL syntax):
SELECT
(Field1)
, (Field2)
, *
FROM (Linked Server Name).(Catalog Name).(Library).(TableName)
The only information you're probably missing is the "archive": you can easily find it browsing the Catalogs tree inside your new Linked Server, or just use iSeries Access Navigator tool!
So, in your case, I think the query should be (more or less):
SELECT
FILIO
, DTVLD
, DTVLA
, SEQZA
, CFIMP
, PADRE
, TPVLD
, CMVLD
, *
FROM MYAS400.S242DA0A.ACG_DATV2.ANLE200F
Note that S242DA0A is valid only in my case...
Remember also that:
AS/400 will probably ask you for credentials very often: also if you close and reopen SSMS.
Performance?...better to talk of something else :) ... extract the tables in your Sql Server tables and query them from there! Do it with a simple: SELECT (Fields) INTO myTable FROM (AS/400 table)
I've tried this process many times, I didn't have many troubles (once I get skilled about!)...but only for reading data (as you asked)! Never tried to update data!!!
GOOD LUCK!

How to connect pyodbc to an Access (.mdb) Database file

Here's what I've tried:
-Find Vista's ODBC Data Source Manager* through search,
-Add a new File Data Source*, selecting Driver for Microsoft Access (*.mdb), and selecting my mdb file of interest,
-import pyodbc from python shell and try:
pyodbc.connect("DSN=<that Data Source I just created>")
I get the following error message (Portuguese**):
Error: ('IM002', '[IM002] [Microsoft][ODBC Driver Manager] Nome da fonte de dados n\xe3o encontrado e nenhum driver padr\xe3o especificado (0) (SQLDriverConnectW)')
Which translates as "Data source name not found and no standard driver specified".
What am I doing wrong?
How to get it right?
Also, I searched the web for documentation but found nothing worth much, could anyone recommend any documentation?
*Names may not be completely accurate because my Windows is in Portuguese.
**No, Portuguese doesn't have '3' and '\' as letters, these are misprinted special characters
DSN= is only used for a system or user DSN.
For a DSN File, you need to use FILEDSN=c:\myDsnFile.dsn
http://www.connectionstrings.com/ is your best friend.
I had a similar problem with pyodbc although not with Access but a different ODBC driver.
This is what helped me.
http://robertoschiabel.wordpress.com/2008/02/28/windows-x64-32bit-odbc-vs-64bit-odbc/
(here is the appropriate KB article in case this URL goes away. http://support.microsoft.com/kb/942976/en-us )
Our previous server hardware died and we had to quickly redeploy on a 64 bit OS because that is all we had that was available. Using the normal ODBC admin tool I added the appropriately named DSN but it still claimed it wasn't found. Only when running the special 32-bit version of the ODBC admin, was I able to define a DSN that my script using pyodbc could find.
I use odbc module (included in ActiveState Python), but tested pyodbc and for me works:
#db = odbc.odbc('northwind')
#db = odbc.odbc('Driver={Microsoft Access Driver (*.mdb)};Dbq=Nwind.mdb;Uid=;Pwd=;')
#db = pyodbc.connect('Driver={Microsoft Access Driver (*.mdb)};Dbq=Nwind.mdb;Uid=;Pwd=;')
db = pyodbc.connect('DSN=northwind')
Of course commented connections works too.
I configured nothwind as user DSN so you probably will have to configure your ODBC database connection as User DSN or System DSN, or without configuring in ODBC Administrator you can use ConnectString where you can point at your .mdb file.
It's smart to list your odbc connections with pyodbc to see what are you using. Make sure you use appropriate pyodbc 32 bit Python 32 bit driver. If you want to use 64bit access files you should use 64 bit MS Acceess which provides driver.
sources = pyodbc.dataSources()
keys = sources.keys()
for key in keys:
print key

Resources