Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. Database & SysAdmin
  3. Database
  4. sql stored proc

sql stored proc

Scheduled Pinned Locked Moved Database
questiondatabasehelp
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    ranjjj
    wrote on last edited by
    #1

    The following is the way i want to implement this. that is..to check iff permissiosn()&2=0x2....permissions()&32=0x20 and so on... CREATE PROCEDURE balli @ioparm int output, @oparm int output AS BEGIN SET NOCOUNT ON IF PERMISSIONS() &@ioparm=0x@oparm SELECT 1 ELSE SELECT 0 END The above sql proc gives syntax error..how do i change it?? ranjani

    M 1 Reply Last reply
    0
    • R ranjjj

      The following is the way i want to implement this. that is..to check iff permissiosn()&2=0x2....permissions()&32=0x20 and so on... CREATE PROCEDURE balli @ioparm int output, @oparm int output AS BEGIN SET NOCOUNT ON IF PERMISSIONS() &@ioparm=0x@oparm SELECT 1 ELSE SELECT 0 END The above sql proc gives syntax error..how do i change it?? ranjani

      M Offline
      M Offline
      Mike Dimmick
      wrote on last edited by
      #2

      A couple of problems: your parameters should not be specified as output, because you're passing the values into the stored procedure. The parameters are also badly named - indeed, I'm not sure you need two parameters, because you're just trying to see if a particular flag is set. The syntax error is coming from 0x@oparm. The prefix 0x tells SQL Server that the following characters should be interpreted as a hexadecimal number literal. If you want to do that, specify hex when assigning a value to the parameter, don't include it in the query text. @ isn't a valid character in a hex literal, so SQL Server complains. With that in mind, I would just SELECT PERMISSIONS() and perform the mask operation in client-side code. Testing each bit separately is a waste of network and server resources. In Visual C++, you use the & operator to mask, then == to compare. == has a higher precedence than &, so you need to use brackets to ensure that the AND operation is done first. In VB, use And to mask and = to compare.

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups