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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T14:50:14+00:00 2026-06-09T14:50:14+00:00

This is a bit confusing because it worked before and I added 1 little

  • 0

This is a bit confusing because it worked before and I added 1 little change and I get this error message in my web application. (I do have other cases, I just took out the other cases for simplicity)

Original code that worked before:

ALTER PROCEDURE [dbo].[GetRoles]
(@reportid Decimal, @dom varchar(10))

AS
DECLARE @sql varchar(2000) 
SELECT @sql = 
Case @reportid

WHEN 1 THEN
 'select u.id as userId, u.domain, u.isAdmin, u.email, u.canReport, a.[site], a.bldgNum,  a.dataCenterNum, l.shortName, l.[description], a.canApprove, a.canComplete
    from locAdmin a
    inner join location l on  (a.site=l.site and a.bldgNum = l.bldgNum and a.dataCenterNum = l.dataCenterNum)
    right outer join [user] u on u.id=a.userId and u.domain=a.domain
    where u.isAdmin = 1'
End

EXEC (@sql)

The only change I did was adding

and u.domain = @dom'

after where u.isAdmin = 1′ at the end so it looks like this

where u.isAdmin = 1 and u.domain = @dom'
  • 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-09T14:50:16+00:00Added an answer on June 9, 2026 at 2:50 pm

    You need to add @dom as a parameter when you execute your dynamic SQL.

    Replace EXEC (@sql) with exec sp_executesql @sql, N'@dom varchar(10)', @dom and change DECLARE @sql varchar(2000) to DECLARE @sql nvarchar(2000).

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

Sidebar

Related Questions

Okay, so this is a bit confusing (well to me). I have a string
I'm new to MVVM in silverlight. It's a bit confusing because although I get
This might sound a bit confusing at first. But I have a table with
This I think is simple but a little confused on the error because I
I hope I can explain this problem right, it's a bit confusing for me.
Right this is confusing me quite a bit, i'm not sure if any of
This little bit of syntax has been a bit of a confusion for me
So I have this bit of code for x in range(x1,x2): for y in
I know the title sound confusing and thats because it is. its a bit
I have some code that's currently giving me an error, because recur can only

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.