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 7944697
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T00:37:47+00:00 2026-06-04T00:37:47+00:00

I’ve a table create table user (userId varchar(8) not null, userName varchar(8) not null)

  • 0

I’ve a table

create table user (userId varchar(8) not null, userName varchar(8) not null)
   insert into user
     select 'NAME1','name1'
     union all
     select 'NAME2', 'name2'
     union all
     select 'NAME3','name3'

I’ve used stored procedure for wild card parameters as:

create procedure wildcard_name
@userName nchar(8)=  '%'
as
select * from user
where userName like @userName;

exec wildcard_name 'n%';

the exec statement is not giving any result,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-06-04T00:37:49+00:00Added an answer on June 4, 2026 at 12:37 am

    Did you try running it again? I suspect the exec call is part of the body of your procedure now. How about:

    ALTER PROCEDURE dbo.wildcard_name
      @userName NVARCHAR(8) = '%'
    AS
    BEGIN
      SET NOCOUNT ON;
    
      SELECT userId, userName
        FROM dbo.user
        WHERE userName LIKE @userName;
    END
    GO -- <-- this is important! It tells SSMS that your procedure has ended!
    
    EXEC dbo.wildcard_name N'n%';
    

    Bunch of other suggestions I would be remiss to not mention:

    • You should always specify the schema prefix when creating and calling objects. So CREATE PROCEDURE dbo.wildcard_name, EXEC dbo.wildcard_name, etc.
    • Hopefully your production code does not use SELECT *.
    • Highly recommend using nvarchar instead of nchar for your parameter.
    • Wrap your procedure body with BEGIN / END and don’t be afraid to use indenting to make it much more readable.
    • You’ll usually want to use SET NOCOUNT ON; to prevent n row(s) affected messages from interfering with your results.
    • NVARCHAR parameters should have an N prefix (though I’m confused why you’re alternating between varchar and nchar in the first place – this is two shifts where I’d expect zero).
    • Depending on the collation (and whether you want the search to be case sensitive), you may need to change your where clause using the COLLATE clause.

    EDIT this seems to work just fine for me, so please explain what you are doing differently (and does “did not work” still mean empty result, or something else?):

    enter image description here

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
Basically, what I'm trying to create is a page of div tags, each has
this is what i have right now Drawing an RSS feed into the php,
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I need to clean up various Word 'smart' characters in user input, including but
I have a text area in my form which accepts all possible characters from
public static bool CheckLogin(string Username, string Password, bool AutoLogin) { bool LoginSuccessful; // Trim
I am currently running into a problem where an element is coming back from

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.