Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6852107
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T01:19:52+00:00 2026-05-27T01:19:52+00:00

ALL stored procedure USE [amozeshgah] GO /****** Object: StoredProcedure [dbo].[selectmanageregistercourse] ******/ SET ANSI_NULLS ON

  • 0

ALL stored procedure

USE [amozeshgah]
GO
/****** Object:  StoredProcedure [dbo].[selectmanageregistercourse] ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[selectmanageregistercourse]
@iddore int,
@stateregister int,
@userid nvarchar(350)
AS
declare @str nvarchar(900)
BEGIN
SET @str= 'SELECT tblUserRegisterDore.id, tblUserRegisterDore.idcourse, tblUserRegisterDore.iddore, tblUserRegisterDore.userid, tblUserRegisterDore.coderegister, tblUserRegisterDore.fish, tblUserRegisterDore.date, tblUserRegisterDore.statefish, tblUserRegisterDore.stateregister, tbluser.name, tbldore.name AS namesubcourse, tblmozedore.name AS namecourse, tbluser.family FROM tblUserRegisterDore INNER JOIN tblmozedore ON tblUserRegisterDore.idcourse = tblmozedore.id INNER JOIN tbldore ON tblUserRegisterDore.iddore = tbldore.id AND tblmozedore.id = tbldore.idmozedore INNER JOIN tbluser ON tblUserRegisterDore.userid = tbluser.userid where  iddore='+convert(nvarchar(100),@iddore)
 if (@stateregister<>-1)
begin
set @str +=' and stateregister='+ convert(varchar(100),@stateregister)
end 
if (@userid <>'-1')
begin
set @str +=' and tblUserRegisterDore.userid='+ @userid
end
EXEC sp_executesql @str 
END

when run query vlaue @userid in where error ‘Invalid column name value @user id’

parameters that are passed

EXEC    @return_value = [dbo].[selectmanageregistercourse]
        @iddore = 3,
        @stateregister = 1,
        @userid = N'fdfsdf'

error
Msg 207, Level 16, State 1, Line 1
Invalid column name ‘fdfsdf’.

why?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T01:19:53+00:00Added an answer on May 27, 2026 at 1:19 am

    There are many issues here and it seems the file you are showing is not the one you are using on the server.

    Here is how to create SP and not use dynamic SQL — it will be much faster and easier to use:

    SET ANSI_NULLS ON
    GO
    SET QUOTED_IDENTIFIER ON
    GO
    ALTER PROCEDURE [dbo].[selectmanageregistercourse]
    @iddore int,
    @stateregister int,
    @fish nvarchar(350)
    AS
    BEGIN
        SELECT tblUserRegisterDore.id, tblUserRegisterDore.idcourse, tblUserRegisterDore.iddore, 
               tblUserRegisterDore.userid, tblUserRegisterDore.coderegister, tblUserRegisterDore.fish, tblUserRegisterDore.date, 
               tblUserRegisterDore.statefish, tblUserRegisterDore.stateregister, tbluser.name, tbldore.name AS namesubcourse, 
               tblmozedore.name AS namecourse, tbluser.family 
        FROM tblUserRegisterDore 
        INNER JOIN tblmozedore ON tblUserRegisterDore.idcourse = tblmozedore.id 
        INNER JOIN tbldore ON tblUserRegisterDore.iddore = tbldore.id AND tblmozedore.id = tbldore.idmozedore 
        INNER JOIN tbluser ON tblUserRegisterDore.userid = tbluser.userid 
        WHERE iddore=@iddore
         AND ((@stateregister =-1) OR (stateregister=@stateregister))
         AND ((@fish ='-1') OR (tblUserRegisterDore.fish=@fish))
    END
    

    Prior comment no longer applies if you use above

    However, here is one issue. You have a varchar and you are not using quotes around it in the dynamic sql you are creating.

    set @str +=' and tblUserRegisterDore.fish='+ @fish
    

    should be

    set @str +=' and tblUserRegisterDore.fish='''+ @fish + ''''
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

At all times I use CHARINDEX in stored procedure to check NVARCHAR(MAX) type of
My insert stored procedure: ALTER procedure proj_ins_all ( @proj_number INT, @usr_id INT, @download DATETIME,
I have a stored procedure that returns all fields of an object. CREATE PROCEDURE
Below is my stored procedure. I want use stored procedure select all row of
Using the stored procedure sp_msforeachtable it's possible to execute a script for all tables
Is there any alternate way to create stored procedure without putting all query in
I'd like to write a stored procedure in SQL 2005 to script all my
I want to do following: Make Oracle stored procedure for read all data from
I am dealing with the following problem: I use a MSSQL Stored Procedure for
Can I use varchar parameters in my stored procedure without declaring its length? For

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.