Create Table Using Selected Result

Posted: May 13, 2012 in SQL Server
Tags: , , , , , ,

Last week i got a simple work to create a table with the result of different tables. We can also create a view to see a single result set from different table but my task was to create a table.

I begin with a simple select statement which will show me the desired result. Now after this we will convert the select statement in select into statement.

Select Into

Select Into statements are used to create tables with the same schema and the data which is returned from the select statement.

Syntax of select into

Select * into tablename from oldtablename

Examples Of select into

Select * into new_test from old_test

Select into in joins

Select a.id,b.newid into new_test from oldtablename a <a class="zem_slink" title="Join (SQL)" href="http://en.wikipedia.org/wiki/Join_%28SQL%29" rel="wikipedia" target="_blank">inner join</a> tbl b on a.id=b.id

Try it in your development and i will be back with some more.

Advertisements

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s