I am stuck in a situation where I need to extract the number of servers from the SQL connection.
I do have a datatable consisting of all the server names only.
What I need is to use some container (mostly a string), so that I have the coma separated pattern as shown below:- strArray1 = " ‘Server A’, ‘Server B’, ‘Server C’, ‘Server D’, ‘Server E’, ‘Server F’ "
And this very same string variable can be passed into the SQL DB query as shown below:-
“SELECT TOP (10000) [ServerName] FROM [ServerInfo].[dbo].[vServersAllDetails] WHERE [ServerName] NOT IN (” +strArray1 +")"
I hope you understand the scope for the string variable in my case.
Although, I got the solution to this and also tried it, but got an error saying that such a long string of input cannot be passed into a query as a variable.
Also, please feel free to give your inputs in this regard and give any other kind of approach to proceed.
Thanks and Regards,