SQLTeam.com | Weblogs | Forums

Using csv to select data from sql table

Hi There,
I have a csv file with a column ("baseid" that relates to a column in an sql table.
How can I use the values of each record in the .csv to run a select statement on the sql table.

Thanks for your help.

Best Regards,

Steve.

You can copy paste the CSV column
Into tsql ..

Using temp table

Create table #tempfromcsv
(
Columnfromcsv int
)
Go

Insert into #tempfromcsv select 1345
Insert into #tempfromcsv select 6666
....
....
.....

Or
You can directly create a separate table with
Column

You can copy paste from CSV column into this SQL table column from ssms
SQL server management studio...

Is this a one time thing only or will this be a continuous process?

If it's a one-time thing, you could use OpenRowset to open it as a 'table' or maybe even import it to a temp table, then use as needed. I wouldn't put this into a production environment