Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

Troubleshooting
Research
Professional Opinions
Ask a Question
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

troubleshooting Question

T SQL Problem

Avatar of nagdotnet
nagdotnet asked on
ASP.NETMicrosoft SQL Server 2005
32 Comments1 Solution400 ViewsLast Modified:
Can somebody point me out what i  am doing wrong with the attached stored proc code. because i am getting error as below when i pass the values to this SP  

'Msg 102, Level 15, State 1, Line 1
Incorrect syntax near '='.
Msg 156, Level 15, State 1, Line 2
Incorrect syntax near the keyword 'and'.
Msg 102, Level 15, State 1, Line 1
Incorrect syntax near '='.
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[uspGetEmployee]
 @FilterType [nvarchar](50),
 @FilterValue[nvarchar](50),
 @startRowIndex int,
 @maxRows int,
 @totalRows int out
   
AS
BEGIN
    SET NOCOUNT ON;
 
	 DECLARE @firstID2 int, @startRow2 int
                      SET @startRow2 = ((@startRowIndex - 1) * @maxRows) + 1
	SET ROWCOUNT @startRow2	
			
	EXEC('SELECT ' + @firstID2 + ' = EmployeeID FROM Employee where ' +   @FilterType + ' like ''%' +@FilterValue + '%'' ORDER BY EmployeeID')
 
	SET ROWCOUNT @maxRows
	EXEC('SELECT EmployeeID, FirstName, LastName, Organization FROM Employee
WHERE EmployeeID >= ' + @firstID2 + ' and ' + @FilterType + ' like ''%' +@FilterValue + '%''')
 
	SET ROWCOUNT 0
 
	 EXEC('SELECT ' + @totalRows + ' = COUNT(EmployeeID) FROM Products where ' + @FilterType + ' like ''%' +@FilterValue + '%''')
           
		
END
ASKER CERTIFIED SOLUTION
Avatar of Sharath S
Sharath SFlag of United States of America imageData Engineer

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Commented:
This problem has been solved!
Unlock 1 Answer and 32 Comments.
See Answers