question

HRugbeer avatar image
HRugbeer asked

SQL not check if queary is correct when create a stored proc

I am running SQL 2008. Recently there has been some change were by When creating a stored proc when executing the save , normally SQL will tell you that you have the incorrect field name or table name. however now it does not and is saving the proc and gives errors only on runtime or or when I execute the proc
tsql
3 comments
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

sqlaj 1 avatar image sqlaj 1 commented ·
Help us help you. Can you share the code? Have you tried running the code without creating the SP? Does it throw the error then? What is the error? .
0 Likes 0 ·
HRugbeer avatar image HRugbeer commented ·
I will give u an example below. Assuming I have a table called testTable with 3 fields called Name,Lastname and IDnumber if I write a statement like below. the queary will still execute. HOwever if I try to run the stored proc I get an error "Invalid object name 'HR_testAAA'" If I run the queary without putting it into aproc I still get the same error. THis will still execute even though I dont have a table named testTable_AAA create proc [TestProc] as select * from testTable_AAA
0 Likes 0 ·
Grant Fritchey avatar image Grant Fritchey ♦♦ commented ·
Please mark any helpful answers by clicking on the thumbs up next to them. The answer that best solved your problem should be indicated by clicking on the check box next to it.
0 Likes 0 ·
sqlaj 1 avatar image
sqlaj 1 answered
Are you sure you are in the database where the Stored Procedure was created? Make sure you are in the correct database and have the correct schema. Best Practice is to prefix the stored procedure in creating and in executing. CREATE PROCEDURE dbo.HR_testAAA AS SELECT * FROM testTable_AAA; EXEC dbo.HR_testAAA; GO
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Dave Morrison avatar image
Dave Morrison answered
Have a look at this MSDN article, it will probably answer your question http://msdn.microsoft.com/en-us/library/ms190686.aspx
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.