0 valutazioniIl 0% ha trovato utile questo documento (0 voti)
5 visualizzazioni1 pagina
The INPUT statement in SQL Server can import data from multiple sources into a table. It supports formats like ASCII, fixed-length, and file formats like Excel and FoxPro. The INPUT statement can automatically create the target table if it does not exist when using certain file formats. However, it has limitations in that supported file formats are limited, and the user does not have control over data types or constraints. It is better to explicitly create tables before using the INPUT statement. The column name list in the INPUT statement can be used to change the column import order or skip columns if there is no corresponding input field.
The INPUT statement in SQL Server can import data from multiple sources into a table. It supports formats like ASCII, fixed-length, and file formats like Excel and FoxPro. The INPUT statement can automatically create the target table if it does not exist when using certain file formats. However, it has limitations in that supported file formats are limited, and the user does not have control over data types or constraints. It is better to explicitly create tables before using the INPUT statement. The column name list in the INPUT statement can be used to change the column import order or skip columns if there is no corresponding input field.
The INPUT statement in SQL Server can import data from multiple sources into a table. It supports formats like ASCII, fixed-length, and file formats like Excel and FoxPro. The INPUT statement can automatically create the target table if it does not exist when using certain file formats. However, it has limitations in that supported file formats are limited, and the user does not have control over data types or constraints. It is better to explicitly create tables before using the INPUT statement. The column name list in the INPUT statement can be used to change the column import order or skip columns if there is no corresponding input field.
3 NULL NULL NULL 0 4 ' double quoted padded string ' 0.00 2003-09-30 00:00:00.000 -111 One advantage the INPUT statement has over LOAD TABLE is the ability to read input from several different sources. INPUT doesnt support FORMAT BCP, but it does support FORMAT ASCII, FORMAT FIXED for fixed-length input fields, and several self-describing file formats: DBASEII, DBASEIII, EXCEL, FOXPRO, and LOTUS, as well as FORMAT DBASE, which means I dont know whether the file is in dBaseII or dBaseIII format, so let the INPUT statement figure it out. The INPUT statement will actually create the target table if it doesnt exist, if you use a FORMAT DBASE, DBASEII, DBASEIII, EXCEL, FOXPRO, or LOTUS input file. This is certainly a quick and easy way to get data into your database, but it does have drawbacks: The supported file formats are limited (Excel version 2.1, for example), you dont have control over target data types or constraints, and some input data types arent supported at all. For these rea- sons, its better to explicitly create your tables before executing the INPUT statement, or to use the proxy table facility described in Section 1.14.4, CREATE EXISTING TABLE. The INPUT statements ability to create tables wont be discussed any further. The column name list can be used with FORMAT ASCII and FORMAT FIXED input for two purposes: to change the order in which input fields are applied to columns in the table and to skip columns for which there is no corre- sponding input field. n To change the order, code the column names in the order in which the cor- responding input fields actually appear in the file. n To skip a column in the table, leave its name out of the list. Unlike the LOAD TABLE input name list, the INPUT column name list cannot be used to skip input fields that are not to be copied into any column; there is no equivalent to the "filler()" notation available with LOAD TABLE. If the column name list is omitted, the layout of the input file is assumed to match the layout of the table (i.e., there are the same number of input fields as there are columns in the table, and they are arranged left to right in each input record in the same order as the columns appear in the CREATE TABLE). Here is an example of an INPUT command using an explicit column name list; the second, third, fourth, and fifth input fields are applied to col_5, col_4, col_3, and col_2, respectively. Note that the keyword INPUT must come first but the rest of the options can appear in any order. CREATE TABLE t1 ( key_1 INTEGER NOT NULL, col_2 INTEGER NOT NULL, col_3 TIMESTAMP NULL, col_4 DECIMAL ( 11, 2 ) NULL, col_5 VARCHAR ( 100 ) NULL, PRIMARY KEY ( key_1 ) );
INPUT ( key_1, col_5, col_4, col_3, col_2 ) FROM 'c:\\temp\\t1_e.txt' INTO t1 ;