* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
Download Análisis de Sets de Productos – 4 Ases
Survey
Document related concepts
Oracle Database wikipedia , lookup
Tandem Computers wikipedia , lookup
Microsoft Access wikipedia , lookup
Entity–attribute–value model wikipedia , lookup
Extensible Storage Engine wikipedia , lookup
Team Foundation Server wikipedia , lookup
Functional Database Model wikipedia , lookup
Microsoft Jet Database Engine wikipedia , lookup
Clusterpoint wikipedia , lookup
Database model wikipedia , lookup
Relational model wikipedia , lookup
Transcript
Bit Sistemas Versión:1.0 Autor: Miguel Cukerman/ Rol: Director 09:14 13/08/2017 Proyecto: Nombre de Proyecto Acceso a Bit por Excel Uso de SQL en Excel para acceder a datos de Bit Add In de Excel Instalar XLodbc Siguiendo estas instrucciones To enter data in Excel, you can either type it in or import it from different sources. It’s easy to import data from a standard .CSV format, but what about importing it from a database? You can directly run SQL queries on a database from Excel. The traditional method was to create a Macro and write a long Visual Basic code by using ADO connection to get connected with the source. But, now with the help of SQLRequest method, you can directly execute an SQL query from an Excel worksheet or a macro. It then returns the result as an array, directly to the Excel worksheet. Connect to the database We tried this using MS-SQL 2000 Server for the database and Excel from MS Office XP. To query the database, start Excel, go to the Tools menu and click on Add-Ins. Now select the ODBS Add-In check box. If you don’t find it, then it was probably not installed during the Office installation. One easy way is to go to http://office.microsoft. com/downloads/2002/xlodbc.aspx and download xlodbc.exe from there and run it. Next, create a System DSN (System Data Source Name) by going to Control panel>Administrative tools>ODBS (Data Source). Then go to System DSN tab and click on the Add button. Now, select your Server type (in our case it was the SQL server; you can choose according to you infrastructure) and click on Finish. It will ask for the DSN name (the name by which your connection will be recognized), description of DSN and the SQL Server name. After filling the appropriate data click on Next. It will now ask for the authentication method. Select SQL-Server Authentication and enter the Login Id as “sa”. Adding this Reference will enable the module to use SQL Queries Click on Next, and it will ask you to select the table name. After selecting the appropriate table name click on Next and Finish. Retrieve data To retrieve data from the data source to Excel, insert the formula in a cell in the following format: =SQL.REQUEST(connection_string, output_ref, Driver_prompt, Query_text, col_names_logical) Archivo: D:\81934515.doc Página 1 de 2 Bit Sistemas Versión:1.0 Autor: Miguel Cukerman/ Rol: Director 09:14 13/08/2017 In this, connection_string is the System DSN name. output_ref is a cell reference where you want the completed connection string placed. The latter is used to get the whole table as in array in the Excel sheet, which is discussed below. Proyecto: Nombre de Proyecto Driver_prompt(optional) specifies when the driver prompt will be displayed. If this field is kept blank, it takes a value of 2 by default, which means only the Driver Dialogue box will be displayed if the provided specification is not sufficient for the connection. Query_text is the actual query that is executed on the SQL server. Col_names_logical is a Boolean variable that describes that the field name of any row will be displayed (True) or not (False) in the Excel sheet. Now let’s put some actual data into the formula. =SQL.REQUEST(“DSN=xlcon”, A1, 2, “select name from tab1 where &$C$5& > age”, False) Here, it will try to connect to an SQL Server via the xlcon DSN and execute a query to print the value from the name field, which has a greater value of age field than the value in C5 cell. Ejemplo de uso Va ejemplo de uso. No obtiene datos correctos ya que usa solo el monto en MN de doctrx. Es solamente un ejemplo. 1) 2) 3) 4) 5) La conexión esta en A1 Las tablas las obtiene del resto de la linea 1 Los signos para calcular netos los saca de linea 2 Ver ejemplo de obtención de descripción de Cuenta Los ejemplos de celdas interiores usan filtro por cuenta y rango de fechas. Están hechos para poder copiar de una celda a otra 6) Con F9 se refrescan los datos Archivo: D:\81934515.doc Página 2 de 2