Solution for Running a list of Computer Names against a stored procedure
is Given Below:
I have to add a large number of computers to a vendor database using an encrypted stored procedure. Is it possible to write a T-SQL statement that will pass each of these computer names to the stored procedure from a file like a CSV or from a temporary table?
Please let me know what other information would be helpful in answering this question.
If you put the computer names into a temp table, you can loop through the names and execute the procedure like this:
create table #ComputerNames (ComputerName varchar(100)); -- insert #ComputerNames declare @ComputerName varchar(100); set @ComputerName = (select min(ComputerName) from #ComputerNames); while @ComputerName is not null begin exec xxx.YourStoredProcedure @parameter = @ComputerName; -- Increment the loop: set @ComputerName = (select min(@ComputerName) from #ComputerNames where ComputerName > @ComputerName); end;