SAS Access Database Export : Connection failed - ms-access

I am trying to export SAS Dataset to my local in ".mdb" format (Access Database). I am using Proc Export statement but it gives the error "Connection Failed"
Also, When I tried to achieve this using EG "Export" feature (on top of the editor window), I used "Export xyz as a step in Project" , I could not find access format there though excel, txt etc options were available.
I did Proc Setinit and found that SAS/Access interfact to PC Files is installed.
I am using SAS 9.4, SAS EG 7.12 and Access 2013. The code I used is as below -
proc export data=test
dbms= ACCESS
outfile="M:\SASAnalytics\Test\test1.mdb"
replace;
run;
And When I tried assigning the libname using
libname mdb "M:\AFolder\BFolder\C.mdb"
I got this error - ERROR: Connect: Class not registered.
I guess, there is nothing with the code but the SAS Access Export is not enabled or something. Please suggest what could be the issue and how to resolve that?

I assume your SAS installation is 64-bit and MS Office is 32-bit. If that so, you have to use PC Files as proxy server between SAS and Office. dbms=ACCESS is using standard LIBNAME as connection. In your case dbms=ACCESSCS is needed. Moreover for Access file you must specify file location using DATABASE= statment and table name using OUTTABLE= option in proc export. Complete code:
proc export data=sashelp.class
dbms= ACCESSCS
outtable="Class"
replace;
database = "C:\Class.mdb";
run;
More Access specific options: Microsoft Access Database Files

Related

importing csv to db2

I am trying to import a .csv file with 2 columns (...and just 3 rows...just for testing) using the query:
IMPORT FROM "C:\db2\dtest.csv" OF DEL INSERT INTO TEST_DATA.DTEST (CAR, NICKNAME)
I am getting this error:
SQL0104N: SQL0104N An unexpected token "IMPORT FROM "C:\db2\dtest.csv"
OF DEL" was found following "BEGIN-OF-STATEMENT". Expected tokens may
include: "". SQLSTATE=42601
If I'm just being stupid here please do tell me :)
The IMPORT is not SQL, it is a command. That means you must submit the IMPORT from the Db2 command window (CLP), or from a script, or from a stored procedure . You cannot submit it directly via SQL, unless you use the ADMIN_CMD stored procedure. See the documentation for details and examples. You would use the ADMIN_CMD if you normally interact with databases via a GUI tool.
Using the command line is best ONLY if you will regularly use batch commands, or write scripts in any scripting language - and you are competent at scripting and using command-lines. But this method has pre-requisites especially if the database is on a different hostname or a different Db2-instance than the one you are working with (i.e. the db is remote). For remote databases the database needs to be catalogued via db2 catalog tcpip node .... and db2 catalog database ... commands.
Additionally you must first connect to the database via db2 connect to .... You have to do this regardless of whether the database is local or remote. See docs for details. For local databases you just use db2 connect to dbname where dbname must be your database name.
Using the ADMIN_CMD stored procedure if often easier for new users who are not familiar with using command line tools.
To use the Db2 command window (CLP), you can either use it interactively, or you can use your operating-system shell. On Windows use db2cwadmin.bat to open such a window (for batch or command usage), or run the db2.exe to enter interactive mode. You can then in interactive mode run your import command.
This happened to me when i was importing data from CSV to Sql DB
--In my case this happened because of incorrectly formatted CSV File.
When extracting data from CSV file have a look at the preview of data which will give an idea of where the data is wrong.
It may be because of different characters like , ' ' etc..
--t

SSRS - Importing data from a CSV file to use as a data source on a report server

I am hoping that someone could help me with my problem. I am able to make a local connection to a csv file and import it and use the data within the report. One problem is when I put the report onto a report server. It can't access the file on the local machine.
Would anyone know of a way, possibly using ODBC, to allow the report on the server to view the CSV file on the local machine?
You can use an ODBC connection to connect to a CSV file. You just need to point the ODBC connection at the folder the files are in:
Provider=Microsoft.Jet.OLEDB.4.0;Data Source="\\\\SERVER_NAME\\FOLDER_NAME\\SUB_FOLDER_NAME";Extended Properties="text;HDR=YES;FMT=Delimited"
(Note the double backslashes and header property HDR)
Then select from the filename in your query:
SELECT * FROM FILENAME.TXT

Edit SSIS connections in config file from command line

I generated a SSIS packed by using the SQL Server export wizard utility.
I extract records from an Oracle 11g database and migrate them to SQL Server 2008 R2.
Since I have many oracle databases (test, production) with the same schema, I would like to reuse the created package also for the other environments. The package would be executed via command line and ideally by changing the source and target connection strings according to the different systems.
Is it possible to use the package .config file in order to change the source and target connection?
If so, which are the "keywords" to ensure that a specific connection strig is used for the proper target database?
When you create a SSIS package using wizard ,select the option Don't save sensitive while saving the package
Once the package is saved ,Log in to integration service expand MSDB and then Maintenance Plan folder where you will find your SSIS package .Right Click on the Package and select Run Package
In the connection Manager tab select your datasources .
Then click on command line option .You will get the entire command to execute your package where you can modify the connection strings which you have selected above .
The command might look like
/DTS "\MSDB\PackageName" /SERVER "ServerName"
/CONNECTION DestinationConnectionOLEDB;"\"Data Source=localhost;
Initial Catalog=DBName;Provider=SQLNCLI10;Integrated Security=SSPI;
Auto Translate=false;\"" /CONNECTION SourceConnectionOLEDB;
"\"Data Source=localhost;Initial Catalog=DBName;Provider=SQLNCLI10;
Integrated Security=SSPI;Auto Translate=false;\""
/CHECKPOINTING OFF /REPORTING V
Now in order to execute the package using command prompt
just add dtexec along with the above command.
Change the connection string to execute for different servers

SSIS FlatFile Access via Jet

Is there a way to access FlatFiles with the Microsoft.Jet.OLEDB.4.0 driver in SSIS ?
The acces via the FlatFile Source is much better, it´s just about if there exists a way to do it with the Jet driver.
This seemed an interesting question so I piddled around a bit with it. Yes, you can definitely use the JET driver to read a flat file. HOW TO: Use Jet OLE DB Provider 4.0 to Connect to ISAM Databases See Open Text section
By default, it expects the file to be a CSV but you can specify the formatting in a Schema.INI which would be in the same folder as the connection manager is pointing to.
One thing to note about the CM, it points to the folder of the text files, not a particular file.
When you create your Connection Manager, you will need to go into the All tab (after selecting the Native OLE DB\Microsoft Jet 4.0 OLE DB Provider) and then add Extended Properties. I was able to make it work with a FMT of CSVDelimited and just Delimited (as my sample file was a csv).
Exchanging the commas for tabs in the source file and setting the FMT at TabDelimited did not appear to work in the connection manager property but I did not try creating a schema.ini file as the BOL article indicated.
You cannot define all characteristics of a text file through the
connection string. For example, if you want to open a fixed-width
file, or you want to use a delimiter other than the comma, you must
specify all these settings in a Schema.INI file.
The full value of the ConnectionString on my CM is below
Data Source=C:\tmp\so\;Provider=Microsoft.Jet.OLEDB.4.0;Extended Properties="text;HDR=Yes;FMT=CSVDelimited;";
If the package works fine at design time but goes belly up once it runs, the JET driver is only available as 32 bit so on a 64bit machine as the error message would indicate.
SSIS Error Code DTS_E_CANNOTACQUIRECONNECTIONFROMCONNECTIONMANAGER.
The AcquireConnection method call to the connection manager
"OLEDB_JET" failed with error code 0xC0209303. There may be error
messages posted before this with more information on why the
AcquireConnection method call failed.
The solution to this is to run it from the command-line in 32bit mode like
C:\Program Files (x86)\Microsoft SQL Server\100\DTS\Binn>.\dtexec /file C:\sandbox\SSISHackAndSlash\SSISHackAndSlash\so_JetFlatFile.dtsx

Cannot loop through Excel 2003 files in SSIS 2008

I am trying to execute a SSIS 2008 package on a 64-bit OS and import Excel 2003 files to SQL Server 2008.
I have created an OLEDB Connection to the Excel file with a Connection String that retrieves the Excel file from a variable, inside the ForEach Loop Container.
The Run64BitRunTime is set to false.
I am not able to edit the SQL Command on the OLEDB Source in the Data Flow task. It returns an error :
Error 2 Validation error. Load List Staged Table: Load List Staged Table: SSIS Error Code DTS_E_CANNOTACQUIRECONNECTIONFROMCONNECTIONMANAGER. The AcquireConnection method call to the connection manager "List OLEDB to Excel" failed with error code 0xC0202009. There may be error messages posted before this with more information on why the AcquireConnection method call failed. 0 0
Appreciate any help.
Check this out:
http://dougbert.com/blogs/dougbert/archive/2008/06/16/excel-in-integration-services-part-1-of-3-connections-and-components.aspx
I've had problems with excel on 64 bit systems - You'll have to run the 32 bit dtexec for the job. Why you are getting errors inside BIDS, I don't know.
Yes, I am running BIDS on a 64-bit OS.
I resolved the issue by using an Excel Connection Manager in the Control Flow and an Excel source in the Data Flow Task instead of the OLEDB source and assigning a default workbook name to the variable. I also made changes to the data access mode in the Source editor.
Thanks for the response.