Roy Ashbrook

let go or be dragged
posts - 197, comments - 29, trackbacks - 8

October 2007 Entries

chunking binary or xml into sql

this is a little unique of a setup. i'm having to update a varbin field, but the data that is coming in from the other sources is being cast from xml. so i'm sort of replicating the stupid thing we are doing on the other side, but it seems like a good code sample for this particular method. if you wanted to chunk up xml, you could use this method.   using (SqlConnection cn = new SqlConnection(cs)) { string staging_sql = @" create table ##t (t varchar(max)); insert ##t select ''; ";   update tablewithvarbincolumn set varbincolumn = cast(cast( (select top 1 t from ##t) as xml) as varbinary(max)) where id1= @a and id2= @b; drop...

posted @ Monday, October 29, 2007 2:28 PM | Feedback (0) | Filed Under [ DEV ]

chunking varbinary into sql2005

//reference this metholodogy justification at // http://www.lacoude.com/Docs/public/public.aspx?doc=SQL90XML.PDF int bufferSize = 0; byte[] buffer = new byte[8040]; string update_sql = @"update tablewithblobs set blobcolumn .write(@a,null,0) where id = @b"; using (FileStream fs = File.Open(abinaryfilepath, FileMode.Open, FileAccess.Read)) using (BinaryReader br = new BinaryReader(fs)) using (SqlConnection cn = new SqlConnection(cs)) using (SqlCommand cmd = new SqlCommand(update_sql, cn)) { cmd.CommandTimeout = 0; cmd.Parameters.Add("@a", SqlDbType.VarBinary, bufferSize); cmd.Parameters.AddWithValue("@b", v1); cn.Open(); while ((bufferSize = br.Read(buffer, 0, buffer.Length)) != 0) { cmd.Parameters[0].Value = buffer; cmd.ExecuteNonQuery(); } cn.Close(); }     note that you will have to zero out the field if it's not empty by setting it to 0x0 first.

posted @ Friday, October 26, 2007 10:56 PM | Feedback (0) | Filed Under [ DEV ]

HTTP Status and SubStatus codes

  HTTP Status HTTP SubStatus Definition 100   ...

posted @ Thursday, October 4, 2007 3:17 PM | Feedback (0) | Filed Under [ SA ]

Powered by: