﻿<?xml version='1.0' encoding='UTF-8'?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>SQLServerCentral / Programming / General  / Syntax request needed. Merge an 'openquery' select towards linkedserver / Latest Posts</title><generator>InstantForum.NET v2.9.0</generator><description>SQLServerCentral</description><link>http://www.sqlservercentral.com/Forums/</link><webMaster>notifications@sqlservercentral.com</webMaster><lastBuildDate>Tue, 18 Jun 2013 17:13:18 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: Syntax request needed. Merge an 'openquery' select towards linkedserver</title><link>http://www.sqlservercentral.com/Forums/Topic1390052-23-1.aspx</link><description>Thank you ! now the output is as I wanted.</description><pubDate>Mon, 03 Dec 2012 07:03:27 GMT</pubDate><dc:creator>johnnyrmtl</dc:creator></item><item><title>RE: Syntax request needed. Merge an 'openquery' select towards linkedserver</title><link>http://www.sqlservercentral.com/Forums/Topic1390052-23-1.aspx</link><description>you just need to add an alias, sorry:[code]select * from openquery([abc],'SELECT                                  myAlias.ServerName,                                 DB.*,                                   CONVERT(VARCHAR(25), DB.name) AS dbName                                from sys.databases DB                               CROSS JOIN (select                                              name As ServerName                                           from sys.servers                                            where server_id =0) myAlias')[/code]</description><pubDate>Fri, 30 Nov 2012 14:49:23 GMT</pubDate><dc:creator>Lowell</dc:creator></item><item><title>RE: Syntax request needed. Merge an 'openquery' select towards linkedserver</title><link>http://www.sqlservercentral.com/Forums/Topic1390052-23-1.aspx</link><description>Actually i don't need @@version. need something like thisabc    master	1	NULL	0x01abc     tempdb	2	NULL	0x01abc    model	3	NULL	0x01abc     msdb	4	NULL	0x01select * from openquery([abc],'SELECT *, CONVERT(VARCHAR(25), DB.name) AS dbName from sys.databases DB')and select * from openquery([abc],'select name from sys.servers where server_id =0')  getting this error Duplicate column names are not allowed in result sets obtained through OPENQUERY and OPENROWSET. The column name "name" is a duplicate.</description><pubDate>Fri, 30 Nov 2012 13:00:20 GMT</pubDate><dc:creator>johnnyrmtl</dc:creator></item><item><title>RE: Syntax request needed. Merge an 'openquery' select towards linkedserver</title><link>http://www.sqlservercentral.com/Forums/Topic1390052-23-1.aspx</link><description>in that case, assuming you wanted the value as columns again like your first query, it would go like this...notice i did a simple cross join, on a table we know has just one row.[code]select * from openquery([abc],'SELECT                                  myAlias.name,                                 myAlias.VersionInfo,                                 DB.*,                                   CONVERT(VARCHAR(25), DB.name) AS dbName                                from sys.databases DB                               CROSS JOIN (select                                              name,                                              @@version As VersionInfo                                            from sys.servers                                            where server_id =0) myAlias')[/code]</description><pubDate>Fri, 30 Nov 2012 12:55:36 GMT</pubDate><dc:creator>Lowell</dc:creator></item><item><title>RE: Syntax request needed. Merge an 'openquery' select towards linkedserver</title><link>http://www.sqlservercentral.com/Forums/Topic1390052-23-1.aspx</link><description>I need more help with another query towards a linked server ... pardon my ignorance with the syntax :)I'm trying to merge these two queries to get the linkedserver along with all databases from it's instance.select * from openquery([abc],'SELECT *, CONVERT(VARCHAR(25), DB.name) AS dbName from sys.databases DB')and select * from openquery([abc],'select name, @@version from sys.servers where server_id =0')</description><pubDate>Fri, 30 Nov 2012 12:03:46 GMT</pubDate><dc:creator>johnnyrmtl</dc:creator></item><item><title>RE: Syntax request needed. Merge an 'openquery' select towards linkedserver</title><link>http://www.sqlservercentral.com/Forums/Topic1390052-23-1.aspx</link><description>Thanks ... that's works :)I was trying to separate both queries.</description><pubDate>Wed, 28 Nov 2012 13:53:04 GMT</pubDate><dc:creator>johnnyrmtl</dc:creator></item><item><title>RE: Syntax request needed. Merge an 'openquery' select towards linkedserver</title><link>http://www.sqlservercentral.com/Forums/Topic1390052-23-1.aspx</link><description>why not the two values in the same query? just an oversight?[code]select * from openquery([linkedserver here],'select   name,  @@version from sys.servers where server_id =0')[/code]</description><pubDate>Wed, 28 Nov 2012 13:46:20 GMT</pubDate><dc:creator>Lowell</dc:creator></item><item><title>Syntax request needed. Merge an 'openquery' select towards linkedserver</title><link>http://www.sqlservercentral.com/Forums/Topic1390052-23-1.aspx</link><description>hello all,How can I merge these two queries to produce one row?i.e TESTSERVER |  VERSIONselect * from openquery([linkedserver here],'select name from sys.servers where server_id =0')select * from openquery([linkedserver here],'SELECT @@version AS [VERSION]')thanks in advance</description><pubDate>Wed, 28 Nov 2012 12:15:33 GMT</pubDate><dc:creator>johnnyrmtl</dc:creator></item></channel></rss>