Author |
Topic |
anbaz1976
Starting Member
5 Posts |
Posted - 2008-11-17 : 04:30:43
|
Hi All, I want to create a SQL Script in SQL 2000 for the existing table.my script will do the followings:1. It will add two new columns on the existing table.2. It will copy the existing column1 data to the newly created 2 columnsI am new to SQL Server 2000. so any one please help me to write the script?thanks.With Regards,Anbaz. |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-11-17 : 04:36:20
|
1. ALTER TABLE yourtablename ADD newcol1 datatype,newcol2 datatype 2.UPDATE YourTableSET newcol1=col1,newcol2=col1 |
 |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-11-17 : 04:39:51
|
for syntax related queries, books online should be your best friendhttp://doc.ddart.net/mssql/sql70/aa-az_5.htm |
 |
|
anbaz1976
Starting Member
5 Posts |
Posted - 2008-11-17 : 04:43:56
|
hi visakh16, Thanks. but i want this in a single script. ok, my actual table and columns are the followings:table name: personal_particularcolumn 1 : lan_id (Primary Key)column 2 : passwordcolumn 3 : namecolumn 4 : emp_idand my new columns to be added are the followings:column 5 : gid varchar(50)column 6 : login_id varchar(50)after that i want to update the lan_id column's data to the gid and login_id columns.i am new to sql server, can you please give the sql script for the above?Thanks.With Regards,Anbaz. |
 |
|
karthickbabu
Posting Yak Master
151 Posts |
Posted - 2008-11-17 : 04:47:36
|
ALTER TABLE personal_particular ADD gid varchar(50), login_id varchar(50)UPDATE personal_particular SET gid = lan_id, login_id = lan_id==================================================== you realize you've made a mistake, take immediate steps to correct it. |
 |
|
anbaz1976
Starting Member
5 Posts |
Posted - 2008-11-17 : 04:54:07
|
Hi karthickbabu, Thanks, I am new to SQL Server, i want those things in SQL Script.or How to make SQL Script in SQL Server 2000 with those Alter and Update command and how to execute that?please tell me.with regards,Anbaz. |
 |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-11-17 : 05:03:59
|
quote: Originally posted by anbaz1976 Hi karthickbabu, Thanks, I am new to SQL Server, i want those things in SQL Script.or How to make SQL Script in SQL Server 2000 with those Alter and Update command and how to execute that?please tell me.with regards,Anbaz.
i cant understand what you're looking at? whats the probelm with solutions provided? what do you mean by want them in single script? can you explain? |
 |
|
karthickbabu
Posting Yak Master
151 Posts |
Posted - 2008-11-17 : 05:05:58
|
Yes, Visakh is right.==================================================== you realize you've made a mistake, take immediate steps to correct it. |
 |
|
anbaz1976
Starting Member
5 Posts |
Posted - 2008-11-17 : 05:11:19
|
Hi, I want a SQL script file that will perform both of the Alter table and immmediatly update table actions with the existing records. i don't not know how to create script for the requirement.my current table i may have around 4000 records, so if i open and run the script , it will do create two new columns and immediatly it will update new columns with the existing records. Thanks.With Regards,Anbaz. |
 |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-11-17 : 05:17:06
|
quote: Originally posted by anbaz1976 Hi, I want a SQL script file that will perform both of the Alter table and immmediatly update table actions with the existing records. i don't not know how to create script for the requirement.my current table i may have around 4000 records, so if i open and run the script , it will do create two new columns and immediatly it will update new columns with the existing records. Thanks.With Regards,Anbaz.
and what do you think the posted solutions do? |
 |
|
anbaz1976
Starting Member
5 Posts |
Posted - 2008-11-17 : 05:21:41
|
Hi, Sorry, i am not a technical person.i am a user of my application. but i know how to open sql server and see the tables.that's why i am asking the SQL Script to do those things. because last time my developer given me the script file to open and execute the files. now my devloper is not available. but the change is very urgent. that's why i am asking a script file to execute.thanks.With Regards,Anbaz. |
 |
|
karthickbabu
Posting Yak Master
151 Posts |
Posted - 2008-11-17 : 05:27:15
|
You save those queries in a single file FileName.SQL in your machine.Take and run whenever u needed.==================================================== you realize you've made a mistake, take immediate steps to correct it. |
 |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-11-17 : 05:31:25
|
quote: Originally posted by anbaz1976 Hi, Sorry, i am not a technical person.i am a user of my application. but i know how to open sql server and see the tables.that's why i am asking the SQL Script to do those things. because last time my developer given me the script file to open and execute the files. now my devloper is not available. but the change is very urgent. that's why i am asking a script file to execute.thanks.With Regards,Anbaz.
AS karthick said save the given solution as .sql file in your machine. When you want to run just open the sql file in query analyser using file ->open and click the green button on top to execute. |
 |
|
|