Results 1 to 8 of 8

Thread: [2008] Two Questions, Deleting all the content in a column, and space used by column

  1. #1

    Thread Starter
    Frenzied Member Icyculyr's Avatar
    Join Date
    Aug 2007
    Location
    Australia
    Posts
    1,934

    [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

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    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?
    ??

  3. #3
    Hyperactive Member
    Join Date
    Feb 2006
    Location
    UK
    Posts
    285

    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

  4. #4

    Thread Starter
    Frenzied Member Icyculyr's Avatar
    Join Date
    Aug 2007
    Location
    Australia
    Posts
    1,934

    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

  5. #5
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    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?
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  6. #6

    Thread Starter
    Frenzied Member Icyculyr's Avatar
    Join Date
    Aug 2007
    Location
    Australia
    Posts
    1,934

    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 to review (my computer's internet is broken, (I use my parents computer, when they are not working, which is not often!!)

    Cheers

  7. #7
    Hyperactive Member
    Join Date
    Feb 2006
    Location
    UK
    Posts
    285

    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??!!)

  8. #8
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width