?
Solved

SQL query Error

Posted on 2011-05-09
13
Medium Priority
?
236 Views
Last Modified: 2012-05-11
I'm trying to run this query :
INSERT INTO sn_email ([ContactID_28], [CreateTimeStamp_2], [EditTimeStamp_3], [Logon_25], [Carrier_26], [MergeTimeStamp_4], [PrimaryStatus_27], [UniqueID_1], [TYPEID])
SELECT [ContactID_28], [CreateTimeStamp_2], [EditTimeStamp_3], [Logon_25], [Carrier_26], [MergeTimeStamp_4], [PrimaryStatus_27], [UniqueID_1], [TYPEID]
FROM testImport.dbo.V_EMAIL

But I'm getting this error ?
How do I solve this error ?
0
Comment
Question by:ankouny
  • 3
  • 3
  • 3
  • +3
13 Comments
 
LVL 25

Expert Comment

by:Lee Savidge
ID: 35719677
What error are you getting?

Is Unique_ID created automatically?
0
 
LVL 39

Expert Comment

by:Pratima Pharande
ID: 35719678
what error r u getting ?
your syntax is correct
http://www.1keydata.com/sql/sqlinsert.html

will this table testImport.dbo.V_EMAIL
accessible ?

0
 
LVL 21

Expert Comment

by:Alpesh Patel
ID: 35719722
SELECT [ContactID_28], [CreateTimeStamp_2], [EditTimeStamp_3], [Logon_25], [Carrier_26], [MergeTimeStamp_4], [PrimaryStatus_27], [UniqueID_1], [TYPEID]
INSERT INTO sn_email
([ContactID_28],
[CreateTimeStamp_2],
[EditTimeStamp_3],
[Logon_25],
[Carrier_26],
[MergeTimeStamp_4],
[PrimaryStatus_27],
[UniqueID_1],
[TYPEID]) FROM testImport.dbo.V_EMAIL
0
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 70

Expert Comment

by:Éric Moreau
ID: 35719749
PatelAlpesh, your syntax is incorrect. ankouny has the right syntax.

what is the error you are having ankouny?
0
 
LVL 25

Expert Comment

by:Lee Savidge
ID: 35719785
@PatelAlpesh

The syntax in your query (35719722) is wrong. To do an insert with a select, the syntax given is correct but the error I suspect is because one of the columns is a primary key or an identity column. We'll know when the author provides the error message.
0
 

Author Comment

by:ankouny
ID: 35719879
Here is the error

Msg 512, Level 16, State 1, Procedure TRG_DoNotSend_Reset_OnInsert, Line 16
Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.
The statement has been terminated.
0
 
LVL 39

Expert Comment

by:Pratima Pharande
ID: 35719934
Do you have lone store rpocedure ?

run only your ataement in query analyser , I don't think thare is problem?

cchek with other contnts in SP
0
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 35719947
this sounds like you have a trigger on the table, which is not correctly written.
0
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 35719966
your trigger needs has a sub-select that returns many rows where only one should be. what is the query of your trigger?
0
 
LVL 25

Expert Comment

by:Lee Savidge
ID: 35719967
Could you post the whole stored procedure please? The error is pointing to line 16 but this may not be the cause of the fault.
0
 

Author Comment

by:ankouny
ID: 35719971
How do I know if there is a trigger or no ?
and if there is one how do I disable it ?

Thanks
0
 
LVL 70

Accepted Solution

by:
Éric Moreau earned 1000 total points
ID: 35720051
in your object explorer (in ssms), expand Tables and your testImport.dbo.V_EMAIL table. You will then see "Triggers".
0
 

Author Comment

by:ankouny
ID: 35720257
Problem solved by disabling trigger.

Thanks Guys
0

Featured Post

Become an Android App Developer

Ready to kick start your career in 2018? Learn how to build an Android app in January’s Course of the Month and open the door to new opportunities.

Question has a verified solution.

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

Occasionally there is a need to clean table columns, especially if you have inherited legacy data. There are obviously many ways to accomplish that, including elaborate UPDATE queries with anywhere from one to numerous REPLACE functions (even within…
In this article I will describe the Backup & Restore method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
SQL Database Recovery Software repairs the MDF & NDF Files, corrupted due to hardware related issues or software related errors. Provides preview of recovered database objects and allows saving in either MSSQL, CSV, HTML or XLS format. Ensures recov…
Stellar Phoenix SQL Database Repair software easily fixes the suspect mode issue of SQL Server database. It is a simple process to bring the database from suspect mode to normal mode. Check out the video and fix the SQL database suspect mode problem.

621 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