sql server - T-SQL Using Unsupported Column In Query -
i'm trying query cluster node information sql server 2008 r2 , using following query.
select nodename node, status status_value, status_description status_text, case when is_current_owner = 1 'true' else 'false' end is_current_owner sys.dm_os_cluster_nodes
this works fine on sql serve 2012 , on 2008 r2 according sys.dm_os_cluster_nodes page looks status , status_description aren't available.
is possible run query on 2008 r2 , fill in values unsupported columns? tried using case statements detect sql server version , print default value else 2012 column. seems if status or status description columns present anywhere in query, query fails invalid column.
you ask server version , different depending on response.
declare @sql nvarchar(max) = '' if (select left(cast(serverproperty('productversion') char(10)),2) )='12' begin select @sql = @sql + ' select nodename node, status status_value, status_description status_text, case when is_current_owner = 1 ''true'' else ''false'' end is_current_owner sys.dm_os_cluster_nodes' end else begin select @sql= @sql + ' select nodename node, '''' status_value, '''' status_text, case when is_current_owner = 1 ''true'' else ''false'' end is_current_owner sys.dm_os_cluster_nodes ' end select @sql exec sp_executesql @sql
Comments
Post a Comment