Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Byte Array insertion using bcp

Author  Topic 

nkm
Starting Member

3 Posts

Posted - 2011-01-19 : 14:23:02
Need to insert byte array value in to a column using bcp bulk copy.
Any way?

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2011-01-19 : 14:28:19
What do you mean by byte array value? Please provide an example.

Does the row already exist? You indicated you want to insert into a column, is there only one column? If you want to update a row, then we'll have go about this in another way.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

nkm
Starting Member

3 Posts

Posted - 2011-01-19 : 15:55:28
Its a array of bytes (IPV6 address in bytes)
By preparedstatement i can insert the value using setBytes function.
But i needed this value to be inserted along with another 10 different columns to a table.
Go to Top of Page

Lamprey
Master Smack Fu Yak Hacker

4614 Posts

Posted - 2011-01-19 : 17:23:18
We know nothing about your data (file?) or table structure. Are you asking how to use BCP to import some data or do you not know how to insert a row into a table from some other data source? Are you not trying to store the byte array as a byte array, but rather, convert it to some kind of string or and numeric value for each octet or something? Help us help you.

This link might help you articulate what you trying to do.
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx
Go to Top of Page

nkm
Starting Member

3 Posts

Posted - 2011-01-20 : 05:04:15
Table name : sample

Table structure :

ID int
NAME varchar(30)
IPADDRESS varbinary(16)
mysql query :

load data concurrent local infile 'C:\test.txt' into table sample fields terminated by ',' LINES TERMINATED BY '\r\n' (ID,NAME,@var3) set IPADDRESS = inet_pton(@var3)

Sql Server Equivalent query :

?? using bcp will be appreciated.. Thanks in advance..
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2011-01-20 : 12:39:03
You still haven't provided sample data, so we are unable to help.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page
   

- Advertisement -