عرض مشاركة واحدة
قديم 29-Sep-2015, 11:35 AM   #6
Hafandi
عضو نشيط
 
تاريخ التسجيل: Jun 2007
الدولة: Saudi Arabia
المشاركات: 56
من مواضيعي  
Smile

هل قمت بتشغيل ال sql scripts الخاصة بعملية عمل نسخة من الشركة database على نفس السيرفر ؟

قد تحل لك مشكلتك .
هذا أهم واحد ، وهو الخاص بتعديل بيانات الشركة ID


كود PHP:
--*****************************************************************************
--    
Description:    
--    
Updates any table that contains a company ID or database name value    
--    with the appropriate values as they are stored in the DYNAMICS.dbo.SY01500 table    
--
--******************************************************************************

if 
not exists(select 1 from tempdb.dbo.sysobjects where name '##updatedTables')
     
create table [##updatedTables] ([tableName] char(100))
truncate table ##updatedTables
declare @aaaaaaaaacStatement varchar(255)
declare 
G_cursor CURSOR for
select
case
when UPPER(a.COLUMN_NAMEin ('COMPANYID','CMPANYID')
     
then 'update '+a.TABLE_NAME+' set '+a.COLUMN_NAME+' = 'cast(b.CMPANYID as char(3))
else
     
'update '+a.TABLE_NAME+' set '+a.COLUMN_NAME+' = '''db_name()+''''
end
from INFORMATION_SCHEMA
.COLUMNS aDYNAMICS.dbo.SY01500 bINFORMATION_SCHEMA.TABLES c
where UPPER
(a.COLUMN_NAMEin ('COMPANYID','CMPANYID','INTERID','DB_NAME','DBNAME''COMPANYCODE_I')
     and 
b.INTERID db_name() and a.TABLE_NAME c.TABLE_NAME and c.TABLE_CATALOG db_name() and c.TABLE_TYPE 'BASE TABLE'
set nocount on
OPEN G_cursor
FETCH NEXT FROM G_cursor INTO 
@aaaaaaaaacStatement
WHILE (@aaaaaaaaa@aaaaaaaaaFETCH_STATUS <> -1)
begin
         insert 
##updatedTables select
substring(@aaaaaaaaacStatement,8,patindex('%set%',@aaaaaaaaacStatement)-9)
         
Exec (@aaaaaaaaacStatement)
     
FETCH NEXT FROM G_cursor INTO @aaaaaaaaacStatement
end
DEALLOCATE G_cursor
select 
[tableName] as 'Tables that were Updated' from ##updatedTables 
Hafandi غير متواجد حالياً   رد مع اقتباس