May 12, 2011 at 11:46 pm
hi,
Just I am renaming the one txt file
code :--
Declare @dt datetime ,@SQLstmt varchar(100)
Set @dt=getdate()
set @SQLstmt ='REN c:\ask\sintdat.dat '+convert(varchar(15),@dt,112)+'.txt'
print @SQLstmt
exec xp_cmdshell @SQLstmt
output:--
1. Access is denied.
2. NULL
so, pl. help me which is usefull me advance thanks
ashok
May 13, 2011 at 12:57 am
I believe that it is related to the permissions of the folder where the file is.
Check permissions (security) on the c:\ask folder or the file itself.
You didn't say how/where you are running it from, but make sure that the user has modify access on that folder.
(User would be account that is running SQL Service or SQL Agent or similar - this depends on the context -how/where is code executed)
Sorry, I know this is not precise enough, but if you need additional help, please be more specific with the question.
P.S. Is it really on the local C drive?
May 13, 2011 at 2:52 am
also want to know the correct answer.
May 13, 2011 at 5:27 am
Permission denied means exactly that... can't access the file. Not much else to add to that one.
May 13, 2011 at 9:03 am
xiewei (5/13/2011)
also want to know the correct answer.
See the post above your original...
--Jeff Moden
Change is inevitable... Change for the better is not.
May 14, 2011 at 1:19 am
Hi,
I have given every on permission to my C:\ Drive
even though same error
Thankks
May 14, 2011 at 1:24 am
Hi
I have copied the txt file from c:\ drive to a table (txtid) through bulk insert it is working fine
then same time i want rename the file it is giving the error
the following is my code :--
create table txtid
(
id varchar(200)
)
go
select * from txtid1
/* bulk insert from txt file to table */
bulk insert txtid from 'c:\ASK\SINTDAT.DAT'
with (fieldterminator = ',')
go
/* rename a txt file */
Declare @dt datetime ,@SQLstmt varchar(100)
Set @dt=getdate()
set @SQLstmt ='REN c:\ask\sintdat.dat '+convert(varchar(15),@dt,112)+'.txt'
print @SQLstmt
exec xp_cmdshell @SQLstmt
Thanks
Ashok
May 14, 2011 at 6:13 am
Hi Ashok,
It is almost impossible to help you without more information.
Based on what you described, I believe it is Windows permissions issue.
Could you please:
- write where from you are running that code? (is it job, scheduled task that is running sql, stored procedure etc)
- confirm that .dat file is not open while you are running your code
- write exactly how is security set up on that file and the folder where the file is.
Must be security, just check carefully the full path and make sure that the file inherits permissions from above.
May 14, 2011 at 2:06 pm
ashok_bayyana (5/14/2011)
HiI have copied the txt file from c:\ drive to a table (txtid) through bulk insert it is working fine
then same time i want rename the file it is giving the error
the following is my code :--
create table txtid
(
id varchar(200)
)
go
select * from txtid1
/* bulk insert from txt file to table */
bulk insert txtid from 'c:\ASK\SINTDAT.DAT'
with (fieldterminator = ',')
go
/* rename a txt file */
Declare @dt datetime ,@SQLstmt varchar(100)
Set @dt=getdate()
set @SQLstmt ='REN c:\ask\sintdat.dat '+convert(varchar(15),@dt,112)+'.txt'
print @SQLstmt
exec xp_cmdshell @SQLstmt
Thanks
Ashok
"C:Drive" ... WHICH C:Drive? On the SQL Server? On your desktop? What?
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 9 posts - 1 through 8 (of 8 total)
You must be logged in to reply to this topic. Login to reply