Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

how to make nested select inside insert into to copy one table to another?

Posted on 2011-03-17
2
Medium Priority
?
224 Views
Last Modified: 2012-05-11
hi,

I wanna copy values from one table to another after applying some condition,  so I put nested select in my insert into statement, but this not working !

here is my try:

 
insert into FilteredNumbers (MobileNumber, IntrMobileNumber) values (

select replace(id_txt, '+1', ''), id_txt from dbo.no_generate where id_txt not like '%000%'
and id_txt not like '%111%'
and id_txt not like '%222%'
and id_txt not like '%333%'
and id_txt not like '%444%'
and id_txt not like '%555%'
and id_txt not like '%666%'
and id_txt not like '%777%'
and id_txt not like '%888%'
and id_txt not like '%999%'

and id_txt not like '%012%'
and id_txt not like '%123%'
and id_txt not like '%234%'
and id_txt not like '%345%'
and id_txt not like '%456%'
and id_txt not like '%567%'
and id_txt not like '%678%'
and id_txt not like '%789%'
and id_txt not like '%890%'
and SUBSTRING ( id_txt , 8 , 3 ) <> SUBSTRING ( id_txt , 11 , 3 )
)

Open in new window

0
Comment
Question by:njgroup
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 

Author Comment

by:njgroup
ID: 35158844
I got his error:

Msg 156, Level 15, State 1, Line 3
Incorrect syntax near the keyword 'select'.
Msg 102, Level 15, State 1, Line 24
Incorrect syntax near ')'.
0
 
LVL 4

Accepted Solution

by:
qasim_md earned 2000 total points
ID: 35158858
Try this::::

insert into FilteredNumbers (MobileNumber, IntrMobileNumber)
select replace(id_txt, '+1', ''), id_txt from dbo.no_generate where id_txt not like '%000%'
and id_txt not like '%111%'
and id_txt not like '%222%'
and id_txt not like '%333%'
and id_txt not like '%444%'
and id_txt not like '%555%'
and id_txt not like '%666%'
and id_txt not like '%777%'
and id_txt not like '%888%'
and id_txt not like '%999%'

and id_txt not like '%012%'
and id_txt not like '%123%'
and id_txt not like '%234%'
and id_txt not like '%345%'
and id_txt not like '%456%'
and id_txt not like '%567%'
and id_txt not like '%678%'
and id_txt not like '%789%'
and id_txt not like '%890%'
and SUBSTRING ( id_txt , 8 , 3 ) <> SUBSTRING ( id_txt , 11 , 3 )
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There have been several questions about Large Transaction Log Files in SQL Server 2008, and how to get rid of them when disk space has become critical. This article will explain how to disable full recovery and implement simple recovery that carries…
Hi all, It is important and often overlooked to understand “Database properties”. Often we see questions about "log files" or "where is the database" and one of the easiest ways to get general information about your database is to use “Database p…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question