Click here to Skip to main content
15,113,991 members
Home / Discussions / Database
   

Database

 
GeneralRe: Favour sought from a MySql expert PinPopular
Richard MacCutchan16-Apr-19 23:21
mveRichard MacCutchan16-Apr-19 23:21 
GeneralRe: Favour sought from a MySql expert Pin
Ger Hayden16-Apr-19 23:34
MemberGer Hayden16-Apr-19 23:34 
GeneralRe: Favour sought from a MySql expert Pin
Richard MacCutchan16-Apr-19 23:48
mveRichard MacCutchan16-Apr-19 23:48 
QuestionSQL to retrieve record count for each column of a table with blank, not null, null and distinct count in oracle sql Pin
Member 1422994312-Apr-19 23:35
MemberMember 1422994312-Apr-19 23:35 
AnswerRe: SQL to retrieve record count for each column of a table with blank, not null, null and distinct count in oracle sql Pin
Richard MacCutchan13-Apr-19 0:26
mveRichard MacCutchan13-Apr-19 0:26 
GeneralRe: SQL to retrieve record count for each column of a table with blank, not null, null and distinct count in oracle sql Pin
Member 1422994313-Apr-19 1:40
MemberMember 1422994313-Apr-19 1:40 
GeneralRe: SQL to retrieve record count for each column of a table with blank, not null, null and distinct count in oracle sql Pin
Richard MacCutchan13-Apr-19 2:07
mveRichard MacCutchan13-Apr-19 2:07 
QuestionLinkedServer version Pin
Darrylw9912-Apr-19 5:59
MemberDarrylw9912-Apr-19 5:59 
I am trying to work through a table of linked server names to get their version and productversion

Here is the code I'm using but I need to be able to get the values and use them elsewhere. I cannot get them into parameters. Also despite it populating the output with a list it isn't for each server. I mean its exactly the same info for every server. But its wrong its showing

EG:
Microsoft SQL Server 2017 (RTM) - 14.0.1000.169 (X64)   Aug 22 2017 17:04:49   Copyright (C) 2017 Microsoft Corporation  Express Edition (64-bit) on Windows 10 Enterprise 10.0 <X64> (Build 16299: ) 


BUT should be
Microsoft SQL Server 2012 (SP4-GDR) (KB4057116) - 11.0.7462.6 (X64) 
	Jan  5 2018 22:11:56 
	Copyright (c) Microsoft Corporation
	Standard Edition (64-bit) on Windows NT 6.1 <X64> (Build 7601: Service Pack 1) (Hypervisor)


<pre>BEGIN
DECLARE @srv SYSNAME, @db SYSNAME, @exec NVARCHAR(1024);
DECLARE @serverName NVARCHAR(100)
DECLARE @i INT = 1
DECLARE @ServerCount INT=0
DECLARE @retval nvarchar(1000)  
DECLARE @ParmDefinition nvarchar(500);
DECLARE @sSQL nvarchar(500);

SET @ServerCount = (SELECT COUNT(*) FROM SQLServerList.dbo.ListOfServers)
SET @db = N'tempdb';	

WHILE (@i <= @ServerCount)
	BEGIN
		SET @serverName = (SELECT serverName FROM SQLServerList.dbo.ListOfServers where id = @i) 
		IF @serverName IS NOT NULL 
		BEGIN
			SET @exec = N'' + QUOTENAME(@serverName) + N'.' + N'' + QUOTENAME(@db) + N'.sys.sp_executesql ';

			SELECT @sSQL = N'SELECT ''' + cast(@serverName as nvarchar) + ''',@@VERSION as version,SERVERPROPERTY(''ProductVersion'') AS ProductVersion  ';

			SET @sSQL = @exec + ' ' + @sSQL
			EXEC sp_executesql @sSQL;

		END		
		SET @i = @i + 1			
	END	
	

END

AnswerRe: LinkedServer version Pin
Mycroft Holmes12-Apr-19 13:43
professionalMycroft Holmes12-Apr-19 13:43 
QuestionSQL Interview Pin
Member 1417944312-Apr-19 4:38
MemberMember 1417944312-Apr-19 4:38 
AnswerRe: SQL Interview Pin
Richard MacCutchan12-Apr-19 7:34
mveRichard MacCutchan12-Apr-19 7:34 
GeneralRe: SQL Interview Pin
Member 1417944312-Apr-19 23:36
MemberMember 1417944312-Apr-19 23:36 
GeneralRe: SQL Interview Pin
Richard MacCutchan13-Apr-19 0:20
mveRichard MacCutchan13-Apr-19 0:20 
GeneralRe: SQL Interview Pin
Eddy Vluggen16-Apr-19 3:54
professionalEddy Vluggen16-Apr-19 3:54 
AnswerRe: SQL Interview Pin
#realJSOP16-Apr-19 3:00
mva#realJSOP16-Apr-19 3:00 
QuestionQuerying from multiple tables at the same time - related to correlated subqueries Pin
User 141845817-Apr-19 6:12
MemberUser 141845817-Apr-19 6:12 
AnswerRe: Querying from multiple tables at the same time - related to correlated subqueries Pin
Mycroft Holmes7-Apr-19 13:08
professionalMycroft Holmes7-Apr-19 13:08 
AnswerRe: Querying from multiple tables at the same time - related to correlated subqueries Pin
Eddy Vluggen8-Apr-19 1:44
professionalEddy Vluggen8-Apr-19 1:44 
AnswerRe: Querying from multiple tables at the same time - related to correlated subqueries Pin
CHill6011-Apr-19 7:48
mveCHill6011-Apr-19 7:48 
QuestionHELP WITH SQL QUERY Pin
BrunoPigeon4-Apr-19 18:37
MemberBrunoPigeon4-Apr-19 18:37 
AnswerRe: HELP WITH SQL QUERY Pin
Mycroft Holmes4-Apr-19 21:38
professionalMycroft Holmes4-Apr-19 21:38 
GeneralRe: HELP WITH SQL QUERY Pin
BrunoPigeon4-Apr-19 21:56
MemberBrunoPigeon4-Apr-19 21:56 
GeneralRe: HELP WITH SQL QUERY Pin
GuyThiebaut4-Apr-19 22:06
professionalGuyThiebaut4-Apr-19 22:06 
GeneralRe: HELP WITH SQL QUERY Pin
BrunoPigeon4-Apr-19 22:10
MemberBrunoPigeon4-Apr-19 22:10 
GeneralRe: HELP WITH SQL QUERY Pin
GuyThiebaut4-Apr-19 22:20
professionalGuyThiebaut4-Apr-19 22:20 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.