February 12, 2008 at 7:27 pm
please some one help me on this I am having problem with this cursor:
declare @name varchar(80)
DECLARE product_cursor CURSOR FOR
SELECT name FROM sys.database_principals
where type_desc like '%use%'
and name not in('dbo','guest','INFORMATION_SCHEMA','sys','public')
OPEN product_cursor
FETCH NEXT FROM product_cursor INTO @name
WHILE @@FETCH_STATUS <> 0
BEGIN
drop @name
FETCH NEXT FROM product_cursor INTO @name
END
CLOSE product_cursor
DEALLOCATE product_cursor
:::
it gives me error saying that
Incorrect syntax near '@name'.
Thanks
Pat
February 12, 2008 at 7:58 pm
drop can't take a dynamic parameter.
Use
Exec sp_droplogin @name
or
Exec sp_dropUser @name
Instead
----------------------------------------------------------------------------------
Your lack of planning does not constitute an emergency on my part...unless you're my manager...or a director and above...or a really loud-spoken end-user..All right - what was my emergency again?
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply