Showing posts with label delete. Show all posts
Showing posts with label delete. Show all posts

Monday, March 19, 2012

Execute without Insert

Is there a way to let an account have execute permission on a stored
procedure but not let that stored procedure run insert , delete, or
update records. Basically only let them run or create stored
procedures that do selects.[posted and mailed, please reply in news]

HD (harlan@.elementalcomponents.com) writes:
> Is there a way to let an account have execute permission on a stored
> procedure but not let that stored procedure run insert , delete, or
> update records. Basically only let them run or create stored
> procedures that do selects.

I'm not really sure what you are asking. You could have a user which have
permissions to create procedure, but only has SELECT permissions on the
tables. In such case, the procedures of that user only perform SELECTs,
no updates.

But if you are asking if you somehow can say that a user may only execute
stored procedures that performs read-only operations, there is no way
to do this by a single setting, at least not what I can think of.

But you can of course grant execute permissions selectively. And to find
out which procedures that performs updates, you can use this select:

select name
from sysobjects o
where o.type = 'P'
and exists (select *
from sysdepends d
where d.id = o.id
and d.resultobj = 1)

However, a word of caution is that this query may not return all updating
procedures. For instance, if you create a procedure first and then the
tables it refers to, there will not be any dependencies recorded.

--
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techin.../2000/books.asp

Sunday, February 19, 2012

Execute Non Query: Command Text Property has not been initialized

I get this when I delete a row then save data in a data grid view control.
Hints to fix ?Hello
This is not the best group for this problem; you will get better
answers in a .Net group, for example
microsoft.public.dotnet.framework.adonet or
microsoft.public.dotnet.datatools.
It's not my domain, but I suppose that you should check the
DeleteCommand property of the corresponding TableAdapter in the
appropriate DataSet.
Razvan

Friday, February 17, 2012

EXECUTE master.dbo.xp_delete_file

I need to delete a file in a job as a step on a different server.

is there something simillar to this command in sql 2000?

EXECUTE master.dbo.xp_delete_file 0,N'D:\DevBack',N'bak',N'10/16/2006 15:16:22'

and what will the command look like if I need to delete only files older than 3 days?

please help

the command goes across the network

like this

EXECUTE master.dbo.xp_delete_file 0,N'\\100\00\00\02\DevBack',N'bak',N'10/16/2006 15:16:22'

|||--builds the date stamp to reflect the stamp added to the files

DECLARE @.dt datetime
DECLARE @.month varchar(2)
DECLARE @.day varchar(2)
SELECT @.dt=getdate()-1 -- 1 is the files with 1 day old
DECLARE @.builtdate varchar(8)

--this ensures a two digit value in month and day

if(len(MONTH(@.dt)) = 1 )
SET @.month = convert(varchar(2), '0' + convert(varchar(1), MONTH(@.dt)))
else
SET @.month = MONTH(@.dt)

if(len(DAY(@.dt)) = 1 )
SET @.day = convert(varchar(2), '0' + convert(varchar(1), DAY(@.dt)))
else
SET @.day = DAY(@.dt)

--this puts it all together and builds the file name match

SET @.builtdate = convert(varchar(8), convert(varchar(4),YEAR(@.dt)) + @.month + @.day)

declare @.filename varchar(100)

-- this removes all .BAK that contain the datestamp in filename

set @.filename = 'del D:\somefilepath\*'+@.builtdate+'*.BAK'

exec xp_cmdshell @.filename

-- this removes all .TRN that contain the datestamp in filename

set @.filename = 'del D:\somefilepath\*'+@.builtdate+'*.TRN'

exec xp_cmdshell @.filename