/****** Script for SelectTopNRows command from SSMS  ******/
SELECT 
	'INSERT INTO [dbo].[Configuration] ([IpOrg],[ConfigTypeCode],[ConfigCode],[ConfigData]) SELECT ' + CONVERT(VARCHAR,[IpOrg]) + ','''  + [ConfigTypeCode] + ''',''' + [ConfigCode] + ''',''' + [ConfigData] + ''' WHERE NOT EXISTS (SELECT 1 FROM [dbo].[Configuration] WHERE [IpOrg] = ' + CONVERT(VARCHAR,[IpOrg]) + ' AND [ConfigTypeCode] = ''SYSTEM'' AND [ConfigCode] = ''' + [ConfigCode] + ''');' AS INSERT_SQL,
	'UPDATE [dbo].[Configuration] SET [ConfigData] = ''' + [ConfigData] + ''' WHERE [IpOrg] = ' + CONVERT(VARCHAR,[IpOrg]) + ' AND [ConfigTypeCode] = ''SYSTEM'' AND [ConfigCode] = ''' + [ConfigCode] + ''';' AS UPDATE_SQL
	,[IpOrg]
	,[ConfigTypeCode]
	,[ConfigCode]
	,[ConfigData]
FROM
	[dbo].[Configuration]
WHERE
		[ConfigTypeCode] = 'SYSTEM'
	AND	[ConfigCode] IN
		(
		'ADMINNOTIF_EMAIL_ADDR',
		'ANALYTICFILTERS',
		'AUTHTYPE',
		'AXISLABELFONTCOLOUR',
		'AXISLABELFONTFAMILY',
		'AXISTITLEFONTCOLOUR',
		'AXISTITLEFONTFAMILY',
		'BROADCASTINCLUDELINK',
		'CHARTTITLEFONTCOLOUR',
		'CHARTTITLEFONTFAMILY',
		'CHARTTITLEFONTSIZE',
		'COLUMNORDERING',
		'CSVCHARSET',
		'CUSTOMGISCOLOURS',
		'CUSTOMSCHEME',
		'DASHBOARDREPORTLOADINGINDICATOR',
		'DEFAULTINITSORT',
		'DISPLAYMIDDLEINITIAL',
		'DRILLANYWHEREDEFAULT',
		'EMAILBACKGROUND',
		'EMAILSIZELIMIT',
		'EMAILTEMPLATEBODYFONT',
		'EMAILTEMPLATEBODYFONTCOLOR',
		'EMAILTEMPLATEBODYFONTDECORATION',
		'EMAILTEMPLATEBODYFONTSTYLE',
		'EMAILTEMPLATEBODYFONTWEIGHT',
		'EMAILTEMPLATEFOOTERCOLOR',
		'EMAILTEMPLATEFOOTERFONT',
		'EMAILTEMPLATEFOOTERFONTDECORATION',
		'EMAILTEMPLATEFOOTERFONTSTYLE',
		'EMAILTEMPLATEFOOTERFONTWEIGHT',
		'EMAILTEMPLATEFOOTERTOPCOLOR',
		'EMAILTEMPLATELINECOLOR',
		'EMAILTEMPLATEPAGECOLOR',
		'EMAILTEMPLATESALUTATIONFONT',
		'EMAILTEMPLATESALUTATIONFONTCOLOR',
		'EMAILTEMPLATESALUTATIONFONTDECORATION',
		'EMAILTEMPLATESALUTATIONFONTPOINT',
		'EMAILTEMPLATESALUTATIONFONTSTYLE',
		'EMAILTEMPLATESALUTATIONFONTWEIGHT',
		'EMAILTEMPLATESELECTEDLOCALE',
		'EMAILTEMPLATESUBJECTFONT',
		'EMAILTEMPLATESUBJECTFONTCOLOR',
		'EMAILTEMPLATESUBJECTFONTDECORATION',
		'EMAILTEMPLATESUBJECTFONTPOINT',
		'EMAILTEMPLATESUBJECTFONTSTYLE',
		'EMAILTEMPLATESUBJECTFONTWEIGHT',
		'EXTERNALURL',
		'FILTERLOCATION',
		'FILTERWIDTH',
		'FIRSTDAYOFWEEK',
		'GMAPKEY',
		'JAVASCRIPTCHART',
		'JAVASCRIPTCHARTCLIENTORGS',
		'LABELFONTCOLOUR',
		'LABELFONTFAMILY',
		'LDAPBASEDN',
		'LDAPBINDPASSWORD',
		'LDAPBINDUSER',
		'LDAPEMAILATTRIBUTE',
		'LDAPFIRSTNAMEATTRIBUTE',
		'LDAPGROUP',
		'LDAPHOST',
		'LDAPSEARCHATTRIBUTE',
		'LDAPSURNAMEATTRIBUTE',
		'LEGENDFONTCOLOUR',
		'LEGENDFONTFAMILY',
		'LINESHAPES',
		'LOADINGINDICATOR',
		'LOGONPAGE',
		'METRICAGGREGATIONDEFAULT',
		'MULTILANGUAGE',
		'MULTILOGONACTION',
		'NAVIGATION_STYLE',
		'NAVIGATION_STYLE_CREATE_LOCATION',
		'PDFDEFAULTCODISPLAYPAGEBREAK',
		'PDFDEFAULTPAGEBREAK',
		'PDFDEFAULTSCALEIMAGES',
		'PDFDEFAULTSCALETOFIT',
		'REPORTAPPROVALFLAG',
		'REPORTAPPROVALPERSON',
		'REPORTDEFAULTCSVEXPORT',
		'REPORTDEFAULTDOCEXPORT',
		'REPORTDEFAULTEXCELEXPORT',
		'REPORTDEFAULTPDFEXPORT',
		'REPORTDESCFONTCOLOR',
		'REPORTDESCFONTSIZE',
		'REPORTSTYLEDATAFONTCOLOR',
		'REPORTSTYLEDATAPADDINGBOTTOM',
		'REPORTSTYLEDATAPADDINGTOP',
		'REPORTSTYLEDEFAULTCHARTCOLOR',
		'REPORTSTYLEHEADERBACKGROUND',
		'REPORTSTYLEHEADERFONTCOLOR',
		'REPORTSTYLEHEADERFOOTERFONTCOLOR',
		'REPORTSTYLEHEADERFOOTERFONTSIZE',
		'REPORTSTYLEHEADERPADDINGBOTTOM',
		'REPORTSTYLEHEADERPADDINGLEFT',
		'REPORTSTYLEHEADERPADDINGRIGHT',
		'REPORTSTYLEHEADERPADDINGTOP',
		'REPORTSTYLESECTIONTITLEFONTCOLOR',
		'REPORTSTYLESECTIONTITLEFONTSIZE',
		'REPORTSTYLESECTIONTITLEFONTWEIGHT',
		'REPORTTITLEFONTCOLOR',
		'REPORTTITLEFONTSIZE',
		'REPORTTITLEFONTWEIGHT',
		'REPSTYLECROSSTABCOLUMNVALUESBACKGROUND',
		'REPSTYLECROSSTABCOLUMNVALUESFONTDECOR',
		'REPSTYLECROSSTABCOLUMNVALUESFONTFAMILY',
		'REPSTYLECROSSTABCOLUMNVALUESFONTSIZE',
		'REPSTYLECROSSTABCOLUMNVALUESFONTSTYLE',
		'REPSTYLECROSSTABCOLUMNVALUESFONTWEIGHT',
		'REPSTYLECROSSTABCOLUMNVALUESPADBOTTOM',
		'REPSTYLECROSSTABCOLUMNVALUESPADLEFT',
		'REPSTYLECROSSTABCOLUMNVALUESPADRIGHT',
		'REPSTYLECROSSTABCOLUMNVALUESPADTOP',
		'REPSTYLECROSSTABMETRICHEADERFONTDECOR',
		'REPSTYLECROSSTABMETRICHEADERFONTFAMILY',
		'REPSTYLECROSSTABMETRICHEADERFONTSTYLE',
		'REPSTYLECROSSTABMETRICHEADERFONTWEIGHT',
		'REPSTYLECROSSTABMETRICHEADERPADBOTTOM',
		'REPSTYLECROSSTABMETRICHEADERPADLEFT',
		'REPSTYLECROSSTABMETRICHEADERPADRIGHT',
		'REPSTYLECROSSTABMETRICHEADERPADTOP',
		'REPSTYLECROSSTABROWVALUESFONTDECO',
		'REPSTYLECROSSTABROWVALUESFONTFAMILY',
		'REPSTYLECROSSTABROWVALUESFONTSIZE',
		'REPSTYLECROSSTABROWVALUESFONTSTYLE',
		'REPSTYLECROSSTABROWVALUESFONTWEIGHT',
		'REPSTYLECROSSTABROWVALUESPADBOTTOM',
		'REPSTYLECROSSTABROWVALUESPADLEFT',
		'REPSTYLECROSSTABROWVALUESPADRIGHT',
		'REPSTYLECROSSTABROWVALUESPADTOP',
		'REPTYLECROSSTABMETRICHEADERFONTSIZE',
		'SMTP',
		'SMTPPORT',
		'STORYBOARDHEADERLOCK',
		'VIEWAUTOADDFIELDS',
		'VIEWBUILDERGROUPLIMIT',
		'VIEWBUILDERMAXROWS',
		'VIEWDATAPREVIEWDEFAULT',
		'VIEWDATAPROFILING',
		'WATERMARKDISPLAY',
		'XAXISCOLOUR',
		'XGRIDLINECOLOUR',
		'YAXISCOLOUR',
		'YFBROADCASTDISPLAY',
		'YFBROADCASTDISPLAYFILTERVALUES',
		'YFBROADCASTEMAIL',
		'YFNOTIFICATION_COMMENTS',
		'YFNOTIFICATION_DISCUSSIONS',
		'YFNOTIFICATION_DISTRIBUTE',
		'YFNOTIFICATION_SIGNAL',
		'YFNOTIFICATION_STORY',
		'YFNOTIFICATION_TIMELINE',
		'YFNOTIFICATION_USERSETTINGS',
		'YFSUPPORTEMAIL',
		'YGRIDLINECOLOUR',
		'')
