Welcome to
Sign in
|
Help
in
T-SQL (forum)
Romanian Section (group)
(Entire Site)
Search
Home
Blogs
External Feeds
Forums
Photos
Downloads
About Us
»
Romanian Section
»
Intrebari
»
T-SQL
»
Update tabela din fisier csv
Update tabela din fisier csv
Last post 01-19-2010, 2:11 PM by
rsocol
. 4 replies.
Sort Posts:
Oldest to newest
Newest to oldest
Previous
Next
01-19-2010, 12:33 PM
7981
ssandu
Joined on 04-27-2006
db_owner
Update tabela din fisier csv
Reply
Quote
Cum pot face update la o tabela dintr-un fisier csv folosind TSQL ?
Sorin Sandu
Report abuse
01-19-2010, 1:13 PM
7982
in reply to
7981
rsocol
Joined on 10-03-2006
Bucuresti
sysadmin
Re: Update tabela din fisier csv
Reply
Quote
Dacă foloseşti SQL Server 2005 (sau ulterior), poţi să citeşti datele dintr-un fişier CSV cu
OPENROWSET
. Singura chestie este că îţi trebuie un
format file
, pe care poţi să-l faci
de mână sau cu BCP-ul
.
Răzvan
Report abuse
01-19-2010, 1:55 PM
7983
in reply to
7982
ssandu
Joined on 04-27-2006
db_owner
Re: Update tabela din fisier csv
Reply
Quote
Acum ma chinui doar sa fac un select si nu vrea
Am 2 variante
SELECT * FROM OPENROWSET('MICROSOFT.JET.OLEDB.4.0',
'Text;Database=D:\;',
'SELECT * FROM ajutor.csv')
AS source
si
SELECT * FROM OPENROWSET('MSDASQL', 'Driver={Microsoft Text Driver (*.txt; *.csv)}; DefaultDir=D:\;',
'select * from ajutor.csv') AS source
Ambele dau eroare
.... could not find the object 'ajutor.csv'. Make sure the object exists and that you spell its name and the path name correctly."
desi fisierul e acolo.
Sorin Sandu
Report abuse
01-19-2010, 2:06 PM
7984
in reply to
7983
Diana
Joined on 03-21-2006
sysadmin
Re: Update tabela din fisier csv
Reply
Quote
Poti sa si importi csv-ul intr-un tabel si apoi sa folosesti UPDATE / MERGE. In functie de "datele problemei", procedura se poate si automatiza.
Report abuse
01-19-2010, 2:11 PM
7985
in reply to
7983
rsocol
Joined on 10-03-2006
Bucuresti
sysadmin
Re: Update tabela din fisier csv
Reply
Quote
Eu mă refeream la ceva de genul:
SELECT * FROM OPENROWSET(BULK 'c:\test.csv', FORMATFILE = 'c:\test.fmt') AS a;
Răzvan
Report abuse