You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
73 lines
1.8 KiB
73 lines
1.8 KiB
1 year ago
|
|
||
|
|
||
|
|
||
|
DECLARE @database VARCHAR(200)
|
||
|
DECLARE @index int
|
||
|
SET @index = 1
|
||
|
|
||
|
DECLARE dbList cursor for
|
||
|
|
||
|
SELECT name
|
||
|
from master..sysdatabases
|
||
|
WHERE STATUS & 512 != 512
|
||
|
|
||
|
-- AND name IN
|
||
|
-- ( SELECT SUBSTRING(FConnectionString,
|
||
|
-- CHARINDEX('Initial Catalog=',FConnectionString) + LEN('Initial Catalog='),
|
||
|
-- CHARINDEX(';Integrated Security',FConnectionString) - (CHARINDEX('Initial Catalog=',FConnectionString) + LEN('Initial Catalog=')))
|
||
|
-- AS FDbName
|
||
|
-- FROM qd108.saidaodns.dbo.TClientServerConfig AS A,
|
||
|
-- qd108.saidaodns.dbo.TClientInfo AS C,
|
||
|
-- qd108.saidaodns.dbo.TServerInfo AS S
|
||
|
-- WHERE A.FClientId = C.FClientId
|
||
|
-- AND C.FServerId = S.FServerId
|
||
|
-- -- AND S.FHostId = 'qd11'
|
||
|
--)
|
||
|
|
||
|
|
||
|
OPEN dbList
|
||
|
FETCH dbList into @database
|
||
|
while @@FETCH_STATUS=0
|
||
|
BEGIN
|
||
|
DECLARE @CheckSql NVARCHAR(1000)
|
||
|
SELECT @CheckSql = 'SELECT @Biz = (SELECT count(1) FROM ' + @database + '..sysobjects WHERE name = ''TCompany'')'
|
||
|
DECLARE @biz BIT
|
||
|
EXEC sp_executesql @CheckSql,N'@biz BIT out ',@biz out;
|
||
|
SELECT @biz = 0 WHERE @biz IS NULL
|
||
|
|
||
|
IF @biz = 0
|
||
|
BEGIN
|
||
|
FETCH dbList into @database
|
||
|
CONTINUE
|
||
|
END
|
||
|
PRINT @database
|
||
|
|
||
|
DECLARE @sql VARCHAR(MAX)
|
||
|
EXEC ('use '+ @database +
|
||
|
'
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
--print 11
|
||
|
|
||
|
')
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
--DECLARE @cmd VARCHAR(2000)
|
||
|
--SELECT @cmd = 'osql -E -d' + @database + ' -iE:\update.sql'
|
||
|
--EXEC xp_cmdshell @cmd
|
||
|
|
||
|
|
||
|
|
||
|
PRINT ''
|
||
|
FETCH dbList INTO @database
|
||
|
SET @Index = @Index + 1
|
||
|
END
|
||
|
CLOSE dbList
|
||
|
DEALLOCATE dbList
|
||
|
PRINT 'END'
|
||
|
|