Using variable for database name
You dont really need a loop and there is no need to use the undocumented sp_MSforeachdb as there is a better alternative to it - written by Aaron Bertrand.

You can use below tsql - Run in SSMS by pressing CTRL+T:

set nocount on

select 'if OBJECT_ID(''dbo.SDE_server_config'') is not null'+char(10)+'begin '+char(10)+' UPDATE ' + quotename(name) + '.dbo.SDE_server_config SET num_prop_value=0
        WHERE prop_name=CONNECTIONS;' + char(10) + 'end '+char(10)+ 'else print ''there is nothing to update ...!;'''
from sys.databases
where database_id &gt; 4
    and state_desc = 'ONLINE'


You can put above select statement in a variable and do and EXEC and save it in a .sql file and then use sqlcmd to just directly call that .sql file and run it on multiple servers.