Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Can I pass in a csv file to a SQL 2005 SP as the Parameter to store in a Var and then process?

Posted on 2009-03-31
3
153 Views
Last Modified: 2012-05-06
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
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

Open in new window

0
Comment
Question by:wally_davis
3 Comments
 
LVL 12

Assisted Solution

by:udaya kumar laligondla
udaya kumar laligondla earned 200 total points
ID: 24036194
you have to pass the contets of the file to the procedure.  instead of "c:\Nodes.csv"  use the contents of the file
0
 
LVL 25

Accepted Solution

by:
reb73 earned 300 total points
ID: 24036708
Wally_davis,

The procedure is not meant for those volumes (500,000 values) being passed in a single parameter..

You should look at using your c# code to export the values to a staging table and get the procedure to then check against this staging table directly..
0
 

Author Comment

by:wally_davis
ID: 24039053
That's what I thought. Thanks guys!
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article will provide a solution for an error that might occur installing a new SQL 2005 64-bit cluster. This article will assume that you are fully prepared to complete the installation and describes the error as it occurred durin…
This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

808 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question