Friday, February 24, 2012

how to delete a column using script code

hi all

iam having a query , c guys iam having a table in sql with some coulmns in it , i have a column named as country in the table , now wat i want to be done is , i want to delete the column country based on some conditions , i ve to write a script code as : i ve to check if the column is there already or not if its there it shld delete the column or if its not there it shld not show any error and just return empty handed thats all , i dont know wat to be done , so if anyone knows abt it pls do send as soon as possible guys , hopefully waiting for a reply

Note : any dbts pls do mail me again

Venkatesan

I understand this is your first post. Welcome to the forums.

Some info that might help you:

If you want a proper response to your question, you need to explain the facts, provide the table structure(s), some sample data. You dont need to provide your entire HTML code from visual studio. Only relevant code. Any amount of ambiguity or missing information can lead people trying to answer your question away from your post, to a more informative post. Otherwise your post will go down the pages unanswered.

Now, coming back to your question, do you want to delete the column or the values in the column? Posting some sample condition would also help!!

|||

hi dinakar

thanks for ur reply , first let me apologise , c yar i dont have any code to post it here , actually i dont know how to write one , i will explain my req again , 1st i have a table named as tbl_employees which has some columns and in that there is a column named as country , intially for live database that country column will not be there and if clients( i mean in live ) wants to have it , then they can add it , the scenario is like this , so as a developer we used to do it and ensure it that its working in local , after it works we have to put it in live , so that time we cannot delete it manually , for that we have to send a script file to check whether the column is there or not , if its there i have to delete the country column through a query thats wat i dont know how to do , so wat i need is to code to delete the country column itself not the values in it , i think i have explained to u well , waiting for a reply asap, thanks in advance

Venkatesan

|||

ALTER TABLE yourTableDROP COLUMNCountry

|||thanks man

No comments:

Post a Comment