Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 how to insert results from sp_executesql to an exi

Author  Topic 

sishan81
Starting Member

7 Posts

Posted - 2010-07-20 : 06:58:44
Hi,
I used sp_executesql for dynamic sql.
Now I want to insert the results into an existing table by using:
insert into ExistingTable
EXEC sp_executesql @Sql2.
But,I keep getting an error:
Caution: Changing any part of an object name could break scripts and stored procedures.
Msg 8114, Level 16, State 1, Line 1
Error converting data type varchar to numeric.
Why?What does it mean?

sql-programmers
Posting Yak Master

190 Posts

Posted - 2010-07-20 : 07:09:20
Check the result columns type from EXEC sp_executesql @Sql2 and the ExistingTable's data type. There may be a datatype mismatch.


SQL Server Programmers and Consultants
http://www.sql-programmers.com/
Go to Top of Page

sishan81
Starting Member

7 Posts

Posted - 2010-07-20 : 07:14:30
I defined part as numeric and part as char,no?
Set @Sql2='select '' '','' '','' '','' '','' '','' '','' '','' '',cast(0 as numeric),cast(0 as numeric),cast(0 as numeric),cast(0 as numeric),cast(0 as numeric),cast(0 as numeric) from CMP_tempopentr'
Go to Top of Page

sql-programmers
Posting Yak Master

190 Posts

Posted - 2010-07-20 : 07:24:51
Can you provide the ExistingTable's structure

SQL Server Programmers and Consultants
http://www.sql-programmers.com/
Go to Top of Page

sishan81
Starting Member

7 Posts

Posted - 2010-07-20 : 09:43:47
Found one mismatch I didn't notice before. Thanks! you helped me a lot!!
Go to Top of Page
   

- Advertisement -