UPDATE TBIDB_BASE SET CONFIG_VALUE = '1.1.1' where CONFIG_NAME = 'DB_VERSION'
GO
ALTER VIEW [dbo].[VWIDB_BE_ATTRIBUTE] AS
SELECT 
	T.[BE_ID]
	,T2.TITLE AS BE
	,[ATTR_ID]
	,T.DEFAULT_SEARCH_ATTRIBUTE
	,T6.TERM_VALUE AS ATTR_TITLE
	,T1.TYP_ID
	,T1.TYP_ID AS [TYPE_ID]
	,T3.NAME_TYPE AS [TYPE_NAME]
	,T1.VIEW_VISIBLE
	,T1.VIEW_SEQUENCE
	,T5.GUID AS LANG_ID
	,T5.LANG_CODE
	,T.ADDED_WHEN
	,T.ADDED_WHO
	,T.CHANGED_WHEN
	,T.CHANGED_WHO
  FROM 
	[TBIDB_BE_ATTRIBUTE] T INNER JOIN TBIDB_ATTRIBUTE T1 ON T.ATTR_ID = T1.GUID
	INNER JOIN TBIDB_BUSINESS_ENTITY T2 ON T.BE_ID = T2.GUID
	INNER JOIN TBIDB_ATTRIBUTE_TYPE T3 ON T1.TYP_ID = T3.GUID
	INNER JOIN TBIDB_ATTRIBUTE_LANGUAGE T4 ON T1.GUID = T4.ATTRIBUTE_ID
	INNER JOIN TBIDB_LANGUAGE T5 ON T4.LANGUAGE_ID = T5.GUID
	INNER JOIN TBIDB_TERM_VALUE_VARCHAR T6 ON T4.TERM_ID = T6.GUID
  WHERE  
	T1.DELETED = 0 
UNION
SELECT 
	T.[BE_ID]
	,T2.TITLE AS BE
	,[ATTR_ID]
	,T.DEFAULT_SEARCH_ATTRIBUTE
	,T6.TERM_VALUE AS ATTR_TITLE
	,T1.TYP_ID
	,T1.TYP_ID AS [TYPE_ID]
	,T3.NAME_TYPE AS [TYPE_NAME]
	,T1.VIEW_VISIBLE
	,T1.VIEW_SEQUENCE
	,T5.GUID AS LANG_ID
	,T5.LANG_CODE
	,T.ADDED_WHEN
	,T.ADDED_WHO
	,T.CHANGED_WHEN
	,T.CHANGED_WHO
  FROM 
GO


