Hi!
I have an webapp that uses bulk insert to insert data into an sql server. This works fine when sqlserver and webserver is on the same machine. But when i tried to use seperate machines i get access denied message when trying bulk insert. Ive created a share on the webserver where i store the files to be bulk inserted. And I use the appropiate unc path to the file to be bulk inserted in SQL query. I guess it has something with permissions on the share or security.
What permissions do I need to make this work.
Thanks.
Niclas AhlqvistI've never tried a bulk insert using a UNC path to another machine, but at a guess:
You will need to give permission to the account that SQL Server is running in. Often, for security reasons, the account is a machine account so that, if the server is compromised, the SQL Server process cannot damage other parts of the network. If your SQL Server is running in a machine account you will need to give it a domain account to run in so that it can access the file.
Alternatively, copy the file to the SQL Server machine first.sql
Showing posts with label path. Show all posts
Showing posts with label path. Show all posts
Thursday, March 22, 2012
Bulk Insert to load, ...?... to unload
To load data from a file into a table, I use :
BULK INSERT Base.Prop.Table
FROM 'Path of file'
WITH (FieldTerminator='_', RowTerminator='_\n')
What's the command to unload a table to a file ?
Somebody must know... help... please...Originally posted by Karolyn
To load data from a file into a table, I use :
BULK INSERT Base.Prop.Table
FROM 'Path of file'
WITH (FieldTerminator='_', RowTerminator='_\n')
What's the command to unload a table to a file ?
Somebody must know... help... please...
y dont u just use a DTS package to do the load and unload?|||I don't want to use DTS packages because :
1) for the loading------------------
- the VB-SQLServer program is installed on lots of PCs*
- each day, these PCs download new files
- it's the name of the files that determines in witch table it must be loaded
- the structure of table can be changed anyday by distance by the program
So if I use DTS packages, I'll have to create or reconstruct the packages
each time the program wants to load datafiles.
2) for the unloading------------------
- each time the program is shut down, it unloads some data from tables
- the list of these tables can be changed anytime
- the data unloaded contains some calculated colums that depends that is different for each user
So if I use DTS packages, I'll have for each PCs users different packages and I don't want to have differences in each databases
(for maintenance ease).
*more than 3000 users in France|||What about bcp?|||I've got to put a special column delimiter
Can I detemine it with Bcp ?|||Originally posted by Karolyn
I've got to put a special column delimiter
Can I detemine it with Bcp ?
Use format file.|||Format file in the bcp command ?|||Originally posted by Karolyn
Format file in the bcp command ?
bcp {[[database_name.][owner].]{table_name | view_name} | "query"}
{in | out | queryout | format} data_file
[-m max_errors] [-f FORMAT_FILE :)] [-e err_file]
[-F first_row] [-L last_row] [-b batch_size]
[-n] [-c] [-w] [-N] [-V (60 | 65 | 70)] [-6]
[-q] [-C code_page] [-t field_term] [-r row_term]
[-i input_file] [-o output_file] [-a packet_size]
[-S server_name[\instance_name]] [-U login_id] [-P password]
[-T] [-v] [-R] [-k] [-E] [-h "hint [,...n]"]|||Mister 4 star Snail... I bow and thank you.|||Originally posted by Karolyn
Mister 4 star Snail... I bow and thank you.
For France I could do anything ;)
BULK INSERT Base.Prop.Table
FROM 'Path of file'
WITH (FieldTerminator='_', RowTerminator='_\n')
What's the command to unload a table to a file ?
Somebody must know... help... please...Originally posted by Karolyn
To load data from a file into a table, I use :
BULK INSERT Base.Prop.Table
FROM 'Path of file'
WITH (FieldTerminator='_', RowTerminator='_\n')
What's the command to unload a table to a file ?
Somebody must know... help... please...
y dont u just use a DTS package to do the load and unload?|||I don't want to use DTS packages because :
1) for the loading------------------
- the VB-SQLServer program is installed on lots of PCs*
- each day, these PCs download new files
- it's the name of the files that determines in witch table it must be loaded
- the structure of table can be changed anyday by distance by the program
So if I use DTS packages, I'll have to create or reconstruct the packages
each time the program wants to load datafiles.
2) for the unloading------------------
- each time the program is shut down, it unloads some data from tables
- the list of these tables can be changed anytime
- the data unloaded contains some calculated colums that depends that is different for each user
So if I use DTS packages, I'll have for each PCs users different packages and I don't want to have differences in each databases
(for maintenance ease).
*more than 3000 users in France|||What about bcp?|||I've got to put a special column delimiter
Can I detemine it with Bcp ?|||Originally posted by Karolyn
I've got to put a special column delimiter
Can I detemine it with Bcp ?
Use format file.|||Format file in the bcp command ?|||Originally posted by Karolyn
Format file in the bcp command ?
bcp {[[database_name.][owner].]{table_name | view_name} | "query"}
{in | out | queryout | format} data_file
[-m max_errors] [-f FORMAT_FILE :)] [-e err_file]
[-F first_row] [-L last_row] [-b batch_size]
[-n] [-c] [-w] [-N] [-V (60 | 65 | 70)] [-6]
[-q] [-C code_page] [-t field_term] [-r row_term]
[-i input_file] [-o output_file] [-a packet_size]
[-S server_name[\instance_name]] [-U login_id] [-P password]
[-T] [-v] [-R] [-k] [-E] [-h "hint [,...n]"]|||Mister 4 star Snail... I bow and thank you.|||Originally posted by Karolyn
Mister 4 star Snail... I bow and thank you.
For France I could do anything ;)
Sunday, February 19, 2012
Bulk Copy Terror
Hi there,
I'm in dire need for a solution to a "Bulk Insert" problem.
Environmental: SQL 7
The unc path used is a shared folder on the local machine with full rights.
This is the SQL Table:
CREATE TABLE [dbo].[ArgiefTransaksies] (
[TakDepotKodeRef] [char] (4) NULL ,
[HoofraamNommer] [varchar] (2) NULL ,
[Dokumentnommer] [decimal](2, 0) NULL ,
[DataLyn] [varchar] (133) NULL)
Here is the file that I try to upload, TESTFILE.PRN
RZGB|FT|12| |\n
RZGB|FT|12| |\n
RZGB|FT|12| |\n
RZGB|FT|12| |\n
RZGB|FT|12|This is a test|\n
RZGB|FT|12| |\n
RZGB|FT|12|Zone 1 Zone 2|\n
RZGB|FT|12|Hello World||\n
RZGB|FT|12| 5 leading spaces|\n
RZGB|FT|12| Tab(10) - Hello|\n
Here is the SQL statement that I try to use:
Exec sp_dboption 'VKBTakDev', 'select into/bulkcopy', 'TRUE'
BULK INSERT ArgiefTransaksies
FROM '\\HKDATA060XP\Public\TESTFILE.PRN'
WITH
(
DATAFILETYPE = 'char',
FIELDTERMINATOR = '|',
ROWTERMINATOR = '|\n',
MAXERRORS = 0,
CODEPAGE = 'raw'
)
Here is the error that I keep getting...
Server: Msg 7399, Level 16, State 1, Line 1
OLE DB provider 'STREAM' reported an error. The provider did not give any information about the error.
The statement has been terminated.
Regardshttp://support.microsoft.com/default.aspx?scid=kb;en-us;q324122 to workaround the issue.|||Have you tried BCP? See what happens when you go through the BCP wizard and create a format file. If it succeeds try to use it in BULK INSERT.
I'm in dire need for a solution to a "Bulk Insert" problem.
Environmental: SQL 7
The unc path used is a shared folder on the local machine with full rights.
This is the SQL Table:
CREATE TABLE [dbo].[ArgiefTransaksies] (
[TakDepotKodeRef] [char] (4) NULL ,
[HoofraamNommer] [varchar] (2) NULL ,
[Dokumentnommer] [decimal](2, 0) NULL ,
[DataLyn] [varchar] (133) NULL)
Here is the file that I try to upload, TESTFILE.PRN
RZGB|FT|12| |\n
RZGB|FT|12| |\n
RZGB|FT|12| |\n
RZGB|FT|12| |\n
RZGB|FT|12|This is a test|\n
RZGB|FT|12| |\n
RZGB|FT|12|Zone 1 Zone 2|\n
RZGB|FT|12|Hello World||\n
RZGB|FT|12| 5 leading spaces|\n
RZGB|FT|12| Tab(10) - Hello|\n
Here is the SQL statement that I try to use:
Exec sp_dboption 'VKBTakDev', 'select into/bulkcopy', 'TRUE'
BULK INSERT ArgiefTransaksies
FROM '\\HKDATA060XP\Public\TESTFILE.PRN'
WITH
(
DATAFILETYPE = 'char',
FIELDTERMINATOR = '|',
ROWTERMINATOR = '|\n',
MAXERRORS = 0,
CODEPAGE = 'raw'
)
Here is the error that I keep getting...
Server: Msg 7399, Level 16, State 1, Line 1
OLE DB provider 'STREAM' reported an error. The provider did not give any information about the error.
The statement has been terminated.
Regardshttp://support.microsoft.com/default.aspx?scid=kb;en-us;q324122 to workaround the issue.|||Have you tried BCP? See what happens when you go through the BCP wizard and create a format file. If it succeeds try to use it in BULK INSERT.
Subscribe to:
Posts (Atom)