wally_davis
asked on
Can I pass in a csv file to a SQL 2005 SP as the Parameter to store in a Var and then process?
Below I have the following SQL SP.
I wanted to excute the SP from C# and I need to figure a way to pass the file named
"Nodes.csv" into the @Endpoints variable to hold something like 500,000 workstation names.
I right-clicked on the SP named "ExpiredNodes" and in the "Value" column, I attempted to pass in the nodes file like this "c:\Nodes.csv" but it did not work.
Do I have to pass this file in via C# code and if not, whats the trick to passing all the workstation names into the @Endpoint variable in the SP?
Thank you for your help in advance,
Wally
I wanted to excute the SP from C# and I need to figure a way to pass the file named
"Nodes.csv" into the @Endpoints variable to hold something like 500,000 workstation names.
I right-clicked on the SP named "ExpiredNodes" and in the "Value" column, I attempted to pass in the nodes file like this "c:\Nodes.csv" but it did not work.
Do I have to pass this file in via C# code and if not, whats the trick to passing all the workstation names into the @Endpoint variable in the SP?
Thank you for your help in advance,
Wally
USE DBMS
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER Procedure ExpiredNodes
@Endpoints varchar(8000) = NULL -- Pass csv values here like
-- 'Workstation1,Workstation2'
AS
BEGIN
SET NOCOUNT ON
DECLARE @SQL varchar(8000)
SET @SQL = 'SELECT [Name] FROM Nodes WHERE [Name] IN (''' + REPLACE(@Endpoints,',',''',''') + ''')'
EXEC ( @SQL )
END
GO
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER