Ernie
T SQL does not read flat files. I use C# to load them in SQL using an
insert or update command.
T SQL does not commas because it is a common delimiter in SQL. In C# or
another language read the file, use the split command to put the data in a
array..
Use this:
using System.Data.SqlClient;
using(SqlConnection connection = new SqlConnection(_connectionString)){
String query = "INSERT INTO dbo.SMS_PW
(id,username,password,email) VALUES (@id,@username,@password,
@email)";
using(SqlCommand command = new SqlCommand(query, connection))
{
command.Parameters.AddWithValue("@id", "abc");
command.Parameters.AddWithValue("@username", "abc");
command.Parameters.AddWithValue("@password", "abc");
command.Parameters.AddWithValue("@email", "abc");
connection.Open();
int result = command.ExecuteNonQuery();
// Check Error
if(result < 0)
Console.WriteLine("Error inserting data into Database!");
}}
If you do Google:
"c# t sql insert" or "c# t sql connection string" "C# read flat file"
You can figure it out.
On Wed, Oct 4, 2017 at 9:36 AM, Newton, Ernie <[log in to unmask]> wrote:
> Greetings,
>
> I know this is not an SQL listserv, but thought I'd give it a try...
>
> Do any of you know how, using MS SQL, to update a field in a table from a
> comma-delimited file?
>
> Here's what I'm looking at...
>
> My employee table consists of
>
> employee ID,
> name,
> address,
> phone number,
> email address
>
> I have a file consisting of employee ID and email address.
>
> I want to update employee table with email address when employee ID's
> match.
>
> I know how to do this with Suprtool tables, but I don't have Suprtool for
> MS SQL. (sad to say)
>
> Thanks in advance,
>
> Ernie
>
> ________________________________
>
> This message, including any attachments, is intended solely for the use of
> the named recipient(s) and may contain confidential and/or privileged
> information. Any unauthorized review, use, disclosure or distribution of
> this communication(s) is expressly prohibited. If you are not the intended
> recipient, please contact the sender by reply e-mail and destroy any and
> all copies of the original message.
>
> * To join/leave the list, search archives, change list settings, *
> * etc., please visit http://raven.utc.edu/archives/hp3000-l.html *
>
--
Thanks
Kent Wallace
425-306-8327
* To join/leave the list, search archives, change list settings, *
* etc., please visit http://raven.utc.edu/archives/hp3000-l.html *
|