Create a Table from Another table :-

Download Script  from Here
Abstract:

  In this artical we will learn how to create table from another table without creating another table.


Agenda:

1)Create a Table from Another table .
2)Inserting Row from one table  to Another Table.
3)Modify the Data in  Table.
4)Update rows of table in GUI.
5)Computed Columns.


Lets Learn in details,

Create a Table from Another table :-


           To create copy of existing table use the following syntax


select */<Columnn List> into  <New Table Name> From <Old Table Name>


eg.
folowing  table create the copy of the table student form with the name stud


select * into tbl_copy from student


insert table with only specefic columns  or Conditions.


select  *  into tbl_Copy1 from tbl_Emp where FName='abhijit'


while creating a table from another table if you dont


to copy the data then specify a condition on the where clause which will be false


select * into student2 from Student where 1=0


Note
      While creating  a table from another table constraints and  indexes available on existing table will not be copy to new table


------------------------------------------------------------
Inserting Row from one table  to Another Table:-
        
You can insert rows from one tables to another provided those tables have columns with same datatype and for this use the following syntax of insert statement.


insert into <Table Name> <Select Statment>


eg:
insert tbl_Copy(StudentId,FirstName ,LastName )select StudentId,FirstName,LastName from Student


Modify the Data in  Table:-
        
To modify the existing data in that table ,you  have to use update command  that has the following  syntax.


Update <tableName> set <ColName>=<Value>,<ColName>=<Value>.......[Where <Condition>]


Eg:
The following examples update th first name of student id 1 to the ‘suhas’


update Student  set FirstName='Suhas' where StudentId =1


Update rows of table in GUI:


  Open the table by right click on the table in object explorer and choosing “Edit 200 Rows” this will open the table and display all exisiting row in the table.
 Whatever value you want modify ,click on that value modify the value and move to the previous or next to complete the update.


Computed Columns:-


  Computed columns are columns for which rows is automatically computed during insert.


  To create a columns as computed columns ,while creating that table after the columnname use the keyword as   followed by the formula based on which the value has to be computed for that columns.
   For the computed columns ,you cannot specify the datatype while insert   the rows into the table containg computed columns ,you must exclude the computed columns and you can not provide values for computed columns manual.

Eg:


   Following example create table with the name marks crating  the columns total,avg,and grade as computed columns.

create table mark(sid int ,c int,cpp int,sql int,total as c+cpp+sql,aveg as (c+cpp+sql)/3.0,
grade as case
when (c+cpp+sql)/3.0 >=70 then 'First Class'
when (c+cpp+sql)/3.0 >=55 then 'SecondClass'
when (c+cpp+sql)/3.0 >=35 then 'Thired Class'
else
'fail'
End)


Insert values using the following syntax:


insert  mark (sid ,c,cpp,sql)values(1001,25,63,45)


check the data after inserted


select * from mark



  If you want to learn more Details  on MSBI then read my next article,


 If you have any query  then frankly  leave mail me dotnetbyabhipatil@gmail.com


For more article  visit my blog
http://dotnetbyabhipatil.blogspot.in



          

82 comments

Click here for comments
Anonymous
admin
24 March 2015 at 23:22 ×

No more live link in this comments field

Reply
avatar
Anonymous
admin
24 March 2015 at 23:24 ×

No more live link in this comments field

Reply
avatar
Jessycharl
admin
28 March 2015 at 00:25 ×

No more live link in this comments field

Reply
avatar
Unknown
admin
2 April 2015 at 00:18 ×

No more live link in this comments field

Reply
avatar
Anonymous
admin
2 April 2015 at 04:39 ×

No more live link in this comments field

Reply
avatar
Unknown
admin
4 April 2015 at 02:29 ×

No more live link in this comments field

Reply
avatar
Unknown
admin
4 April 2015 at 02:30 ×

No more live link in this comments field

Reply
avatar
glennparyy
admin
4 April 2015 at 05:42 ×

No more live link in this comments field

Reply
avatar
Unknown
admin
15 April 2015 at 01:01 ×

No more live link in this comments field

Reply
avatar
IICT
admin
16 June 2015 at 04:40 ×

No more live link in this comments field

Reply
avatar
Anonymous
admin
24 June 2015 at 02:28 ×

No more live link in this comments field

Reply
avatar
Unknown
admin
25 September 2015 at 00:15 ×

No more live link in this comments field

Reply
avatar
nancy agnes
admin
30 September 2015 at 02:59 ×

No more live link in this comments field

Reply
avatar
Unknown
admin
11 October 2015 at 03:45 ×

No more live link in this comments field

Reply
avatar
Anonymous
admin
8 February 2016 at 04:27 ×

No more live link in this comments field

Reply
avatar
Anonymous
admin
12 February 2016 at 05:55 ×

No more live link in this comments field

Reply
avatar
Anonymous
admin
16 February 2016 at 03:04 ×

No more live link in this comments field

Reply
avatar
Anonymous
admin
16 February 2016 at 21:20 ×

No more live link in this comments field

Reply
avatar
17 February 2016 at 02:32 ×

No more live link in this comments field

Reply
avatar
Haritha
admin
18 February 2016 at 23:01 ×

No more live link in this comments field

Reply
avatar
Haritha
admin
18 February 2016 at 23:08 ×

No more live link in this comments field

Reply
avatar
Jenilia
admin
24 February 2016 at 03:54 ×

No more live link in this comments field

Reply
avatar
raphael
admin
25 February 2016 at 00:00 ×

No more live link in this comments field

Reply
avatar
jayashree
admin
25 February 2016 at 01:18 ×

I got useful information and and thanks for sharing.

Reply
avatar
ravi
admin
25 February 2016 at 01:43 ×

No more live link in this comments field

Reply
avatar
Unknown
admin
25 February 2016 at 02:39 ×

No more live link in this comments field

Reply
avatar
27 February 2016 at 04:11 ×

I really like your post. Thanks for posting this useful information

Reply
avatar
Anonymous
admin
1 March 2016 at 04:21 ×

No more live link in this comments field

Reply
avatar
Hema
admin
1 March 2016 at 23:20 ×

No more live link in this comments field

Reply
avatar
jayashrii
admin
2 March 2016 at 00:54 ×

No more live link in this comments field

Reply
avatar
swarupa
admin
2 March 2016 at 02:53 ×

No more live link in this comments field

Reply
avatar
Unknown
admin
2 March 2016 at 21:55 ×

No more live link in this comments field

Reply
avatar
rekhila
admin
3 March 2016 at 21:41 ×

No more live link in this comments field

Reply
avatar
kala
admin
4 March 2016 at 00:34 ×

No more live link in this comments field

Reply
avatar
Unknown
admin
4 March 2016 at 01:56 ×

No more live link in this comments field

Reply
avatar
4 March 2016 at 04:01 ×

No more live link in this comments field

Reply
avatar
rekhila
admin
5 March 2016 at 00:38 ×

No more live link in this comments field

Reply
avatar
sathya
admin
6 March 2016 at 21:17 ×

No more live link in this comments field

Reply
avatar
Unknown
admin
7 March 2016 at 00:47 ×

No more live link in this comments field

Reply
avatar
Unknown
admin
17 March 2016 at 04:04 ×

No more live link in this comments field

Reply
avatar
Unknown
admin
28 March 2016 at 03:59 ×

No more live link in this comments field

Reply
avatar
Unknown
admin
28 March 2016 at 04:16 ×

No more live link in this comments field

Reply
avatar
Unknown
admin
28 March 2016 at 04:32 ×

No more live link in this comments field

Reply
avatar
Ridhima
admin
2 April 2016 at 06:58 ×

No more live link in this comments field

Reply
avatar
Unknown
admin
22 April 2016 at 04:11 ×

No more live link in this comments field

Reply
avatar
Nicky Paul
admin
25 April 2016 at 04:29 ×

No more live link in this comments field

Reply
avatar
Anonymous
admin
19 May 2016 at 00:33 ×

No more live link in this comments field

Reply
avatar
Unknown
admin
27 May 2016 at 23:49 ×

No more live link in this comments field

Reply
avatar
IICT
admin
20 June 2016 at 00:56 ×

No more live link in this comments field

Reply
avatar
Unknown
admin
27 June 2016 at 23:21 ×

No more live link in this comments field

Reply
avatar
Unknown
admin
4 July 2016 at 00:31 ×

No more live link in this comments field

Reply
avatar
kitharington
admin
7 July 2016 at 05:21 ×

No more live link in this comments field

Reply
avatar
Anonymous
admin
9 July 2016 at 03:31 ×

No more live link in this comments field

Reply
avatar
Anonymous
admin
9 July 2016 at 05:47 ×

No more live link in this comments field

Reply
avatar
Aashi siva
admin
17 July 2016 at 23:56 ×

No more live link in this comments field

Reply
avatar
Anonymous
admin
3 August 2016 at 05:20 ×

No more live link in this comments field

Reply
avatar
Anonymous
admin
3 August 2016 at 05:27 ×

No more live link in this comments field

Reply
avatar
Keerthi
admin
9 August 2016 at 05:06 ×

No more live link in this comments field

Reply
avatar
Unknown
admin
12 August 2016 at 22:42 ×

No more live link in this comments field

Reply
avatar
Anonymous
admin
26 August 2016 at 01:38 ×

No more live link in this comments field

Reply
avatar
Anonymous
admin
23 October 2016 at 02:44 ×

No more live link in this comments field

Reply
avatar
Unknown
admin
26 October 2016 at 04:21 ×

No more live link in this comments field

Reply
avatar
Unknown
admin
26 October 2016 at 04:21 ×

No more live link in this comments field

Reply
avatar
Unknown
admin
3 November 2016 at 04:27 ×

No more live link in this comments field

Reply
avatar
Unknown
admin
22 March 2017 at 04:23 ×

No more live link in this comments field

Reply
avatar
sathya
admin
28 March 2017 at 23:26 ×

No more live link in this comments field

Reply
avatar
18 April 2017 at 08:41 ×

No more live link in this comments field

Reply
avatar
17 May 2017 at 05:28 ×

No more live link in this comments field

Reply
avatar
Unknown
admin
21 August 2017 at 02:41 ×

No more live link in this comments field

Reply
avatar
Aruna Ram
admin
12 December 2018 at 21:30 ×

No more live link in this comments field

Reply
avatar
SANDY
admin
19 January 2019 at 02:56 ×

No more live link in this comments field

Reply
avatar
Unknown
admin
28 May 2019 at 03:48 ×

No more live link in this comments field

Reply
avatar
htop
admin
8 July 2019 at 23:37 ×

No more live link in this comments field

Reply
avatar
shankarjaya
admin
4 August 2020 at 04:10 ×

No more live link in this comments field

Reply
avatar
vivekvedha
admin
14 August 2020 at 04:19 ×

No more live link in this comments field

Reply
avatar
dhinesh
admin
2 September 2020 at 23:57 ×

No more live link in this comments field

Reply
avatar
Tutorials
admin
6 October 2020 at 08:30 ×

No more live link in this comments field

Reply
avatar
Devi
admin
21 June 2021 at 09:02 ×

No more live link in this comments field

Reply
avatar
17 February 2022 at 21:47 ×

No more live link in this comments field

Reply
avatar
manasha
admin
17 March 2022 at 03:22 ×

No more live link in this comments field

Reply
avatar
Aaina
admin
26 May 2022 at 22:38 ×

No more live link in this comments field

Reply
avatar

ConversionConversion EmoticonEmoticon

:)
:(
=(
^_^
:D
=D
=)D
|o|
@@,
;)
:-bd
:-d
:p
:ng