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
 Invalid object name 'dbo.sp_searchdata'.

Author  Topic 

vimaldreams
Starting Member

17 Posts

Posted - 2010-11-01 : 09:51:01
I have created this SP and when am tryng to execute the SP
AM getting the error:

Msg 208, Level 16, State 6, Procedure sp_searchdata, Line 26
Invalid object name 'dbo.sp_searchdata'.


Any help would be appreciated



SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author: <Author,,Name>
-- Create date: <Create Date,,>
-- Description: <Description,,>
-- =============================================
ALTER PROCEDURE [dbo].[sp_searchdata]
(
@mode VARCHAR(20)='select',
@searchfield VARCHAR(50)='DropDownList1.SelectedItem.Text',
@searchvalue VARCHAR(50)='TextBox1.Text'
)
WITH EXECUTE AS 'dbo'
AS
BEGIN
DECLARE @STR VARCHAR(2000)
IF @mode='select'
BEGIN
SELECT @STR = 'select * from MK_DB'

IF @searchfield <> '' AND @searchvalue <> ''
BEGIN
SELECT @STR = @STR + ' Where ' + @searchfield + ' like ' + '''' + @searchvalue + '%'+ ''''
END
PRINT(@STR)
EXEC(@STR)
END
END

vimaldreams
Starting Member

17 Posts

Posted - 2010-11-01 : 10:09:43
Any help would be greatly appreciated
Go to Top of Page

vimaldreams
Starting Member

17 Posts

Posted - 2010-11-01 : 10:25:17
I found the solution:

This line of code
ALTER PROCEDURE [dbo].[sp_searchdata]

is replaced by
CREATE PROCEDURE sp_searchdata_SELECT
Go to Top of Page
   

- Advertisement -