TutorialSqlServer.Com 

Create In Sql Server

Insert In Sql Server 

 Sql Server Select Basic

 Group By In Sql Server


Where in Sql Server
 

Order By in Sql Server
 

 Disclaimer

 Author G+

 

 

 

Insert Query in Sql Server 2005


In sql server 2005 there is a new way introduced to insert row(s) using select statements.
This works in sql server 2005 and later versions.
let`s create a table first 



Create Table
DummyTable2005 ( ID Int , Name Varchar(30) , Age Tinyint )
   

  • Please Note if you don`t define columns nullable or not sql server by default take it as nullable column so above all columns are nullable.

insert into Table in 2005 Syntax :


Insert into TableName
Select 'data' , 'data'

  for inserting  more than one row 

Insert into TableName
Select 'data1' , 'data1' Union All
Select 'data2' , 'data2' 
 

  • Please note Any character  can be insert  using  single Quote ( ' ' ) whether it is numeric  , alphabet or any other special character. but only numeric value can be insert without any quote.

Let`s use this syntax and insert the data in the table.


Insert
Into DummyTable2005

Select
1 , 'Neeraj Prasad Sharma' , 26 Union All

Select
1 , 'Mick Culter' , 32 
 



Insert query in sql server 2005

If  the columns are Nullable (accepts empty values) then we can left those column empty example :

 

Insert Into DummyTable2005 (ID,Name)
Select 3 , 'ronney'


Insert null values in sql server 2005


Let`s now view all  the data of dummytable2005

Select Dummy table2005

DownLoad Script Used
(Right click the link and choose "Save As.." to download this file.)


Please Comment Below :



 

         Related Topics

  1. Insert Query in Sql Server

  2. Insert Query in sql server 2005

  3. Insert Query in Sql Server 2008

comments powered by Disqus