SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 distinct into new table
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

statix
Starting Member

12 Posts

Posted - 02/01/2013 :  10:32:33  Show Profile  Reply with Quote
hi i try to do distinct and insert the data to new table


select distinct states
from datazip
into states.state_name


i tried


select into states.state_name
from datazip.state


i keep geting errors ... :\
any suggestions ?

visakh16
Very Important crosS Applying yaK Herder

India
52325 Posts

Posted - 02/01/2013 :  12:22:35  Show Profile  Reply with Quote
should be

insert states
(state_name)
select distinct states
from datazip


------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

statix
Starting Member

12 Posts

Posted - 02/01/2013 :  12:23:37  Show Profile  Reply with Quote
nevermind guys i found my mistake thx anyway


select distinct <column dest>
into <table dest>
from <table src>
Go to Top of Page

statix
Starting Member

12 Posts

Posted - 02/01/2013 :  12:24:59  Show Profile  Reply with Quote
thx visakh16 i will try your sultion for the sport :) !
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

India
52325 Posts

Posted - 02/01/2013 :  12:26:02  Show Profile  Reply with Quote
quote:
Originally posted by statix

thx visakh16 i will try your sultion for the sport :) !


mine will work if table already exist
yours will create a new table

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

statix
Starting Member

12 Posts

Posted - 02/01/2013 :  13:32:55  Show Profile  Reply with Quote
Thx! yours much better! helped me alot!
Go to Top of Page

statix
Starting Member

12 Posts

Posted - 02/01/2013 :  13:32:56  Show Profile  Reply with Quote
Thx! yours much better! helped me alot!
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

India
52325 Posts

Posted - 02/02/2013 :  03:09:32  Show Profile  Reply with Quote
welcome

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.05 seconds. Powered By: Snitz Forums 2000