Changing a table from my ASP

Results 1 to 2 of 2

Thread: Changing a table from my ASP

  1. #1
    Join Date
    Dec 1969

    Default Changing a table from my ASP

    Is it possible to permanently change a field in a table from int to char in SQL Server? Basically, my client wants to change a field to accept char rather than just ints. Can this be done by sending SQL statements via my ASP to SQL Server 7.0?<BR><BR>My database is small enough that I can change the values of related fields by hand...<BR><BR>I can (I suppose) delete the table and start over -- but however I do it, I need to perform everything through SQL statements.<BR><BR>Code snippets, please?<BR><BR>Thanks...<BR>

  2. #2 Guest

    Default RE: Changing a table from my ASP

    Basically I suggest that you do it in 6 steps. In my example i will refer to your existing int field as "IntF" and your Table as "Tbl" (I have suggested the size of the new text field as 20 incase their are some large values, but you may use something smaller) :<BR><BR>Create new temporary text field<BR>***alter table Tbl add column TmpF text(20);<BR><BR>Update the temporary field with the value from your int field converted to text.<BR>***Update Tbl set TmpF = Str(IntF);<BR><BR>Drop the Int field and reinstate it as a text field<BR>***alter table Tbl Drop field IntF;<BR>***alter table Tbl add column IntF text(20);<BR><BR>Update the new field from the tmp field and drop temp field.<BR>***Update Tbl set IntF = TmpF;<BR>***alter table Tbl drop field TmpF;<BR>

Posting Permissions

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