Tuesday, April 1, 2014

How to execute the output of the below query automatically

put it in a variable and then use exec



declare @sqlcmd varchar(5000)

select @sqlcmd = COALESCE(@sqlcmd,'') + 'alter database ['+name+'] set recovery simple;' from master.sys.databases where database_id > 4 and state_desc = 'online'

EXEC (@sqlcmd)





Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://ift.tt/19nLNVq http://ift.tt/1iEAj0c



No comments:

Post a Comment