Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Why doesn't this work? 1

Status
Not open for further replies.

Gooser

Technical User
Jun 28, 2006
803
US

Code:
INSERT @egbs_1 (
        [risk_id],
	[risk_version_id],
	[contact_id],
	[risk_status_id],
	[risk_status_value],
	[risk_status_nm],
	[city],
	[state_cd],
	[state],
	[postal_cd],
	[extended_postal_cd],
	[county]

) VALUES ( exec sp_executesql @newsql_1 )

@newsql_1 contains a valid select statement. I can't figure out how to get this to work.
 
Other than the missing INTO keyword. ... D'OH!
 
Does it work after you include the missing INTO keyword?

I would probably have written it like this:

Code:
Insert Into @egbs_1 exec @newsql_1



-George
Microsoft SQL Server MVP
My Blogs
SQLCop
"The great things about standards is that there are so many to choose from." - Fortune Cookie Wisdom
 
George, thanks (as usual), it turned out that what I thought held a SELECT statement held some other statements as well. (I didn't write that part.) The other statements declare a variable for a where clause, then set it's value, but they are never used. Yay for SUBSTRING()!

I try to follow best practices, if I can, but I have been dealing with this stored procedure which is essentially filled with WORST practices and I never learned how to do things WRONG so I ham really having problems here. Working with someone else's Dynamic SQL is tough.

I'll start a new thread with my next question in it.

Thanks anyways for the help.

--Gooser
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top