[2008] Two Questions, Deleting all the content in a column, and space used by column
I need to know two things, and would appreciate help with them...
Question 1: I want to delete all the values in my column 'testValue' and in my column ID.
Question 2: I will be storing large amounts of strings and integers (a lot), and I would like to know how to assess how much space in bytes (from bytes I can turn that into kilobytes, and megabytes), does anyone know that?
Thanks alot
Re: [2008] Two Questions, Deleting all the content in a column, and space used by column
At column in what?
A ListView?
A DB table?
An Excel Spreadsheet?
??
Re: [2008] Two Questions, Deleting all the content in a column, and space used by column
A column of what? A datagridview, a database table?
Each character in a string takes two bytes; each data point of int32 (integer in the VB world) takes four bytes:
A = string.length * 2 bytes
B = int32 * no of data points * 4 bytes
(A + B) / 1024 = kilobytes
kilobytes / 1024 = megabytes
Re: [2008] Two Questions, Deleting all the content in a column, and space used by col
mehh! sorry, I wasn't thinking:P
I am referring to a database, a column in a database.
(And I want to use SQL to do this, using SqlCommand in VB)
Thanks
Re: [2008] Two Questions, Deleting all the content in a column, and space used by column
Icy, have you read any SQL tutorisl or reference material? Have you read any ADO.NET tutorials or reference? It seems to me that the answer would be "no", given the flurry of SQL and ADO.NET related questions recently. Would doing so not be a good idea?
Re: [2008] Two Questions, Deleting all the content in a column, and space used by col
Actually I have, ADO.NET, only a little bit (what does this actually cover?)
And I have downloaded an entire SQL tutorial site :D to review (my computer's internet is broken, (I use my parents computer, when they are not working, which is not often!!)
Cheers
Re: [2008] Two Questions, Deleting all the content in a column, and space used by column
update tablename
set testValue='' (Assumes testValue holds strings)
I'm not too happy with this idea of deleting your ID column! Having done so, how do you intend to address individual records? Anyhoo, the technique above should suffice, unless you have an identity column(!) and remember to update the ID column to a value of its data type; or else Null (assuming that you have allowed Null values in an ID column??!!)
Re: [2008] Two Questions, Deleting all the content in a column, and space used by column
alter table tablename drop columnname
Your mileage may vary, given that you didn't say what variant of SQL you're using.