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
  1. Home
  2. Database & SysAdmin
  3. Database
  4. set command error

set command error

Scheduled Pinned Locked Moved Database
sysadminhelp
6 Posts 4 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.
  • V Offline
    V Offline
    veereshIndia
    wrote on last edited by
    #1

    Hi All Iam getting error on executing this procedure Alter procedure LogProc ( @UserId varchar(500), @Password varchar(500) ) as declare @str varchar(500) set @str='select AstId from UserTable where UserId='+@UserId+'and Password='+@Password exec (@str); exec LogProc 'uname','xyz'; Server: Msg 170, Level 15, State 1, Line 1 Line 1: Incorrect syntax near 'Password'.

    i want to join this group

    M J 2 Replies Last reply
    0
    • V veereshIndia

      Hi All Iam getting error on executing this procedure Alter procedure LogProc ( @UserId varchar(500), @Password varchar(500) ) as declare @str varchar(500) set @str='select AstId from UserTable where UserId='+@UserId+'and Password='+@Password exec (@str); exec LogProc 'uname','xyz'; Server: Msg 170, Level 15, State 1, Line 1 Line 1: Incorrect syntax near 'Password'.

      i want to join this group

      M Offline
      M Offline
      Marek Grzenkowicz
      wrote on last edited by
      #2

      Try something like this:

      set @str = 
      ' select AstId 
        from UserTable 
        where UserId = ''' + @UserId 
        + ''' and Password = ''' + @Password + ''''
      
      V 1 Reply Last reply
      0
      • M Marek Grzenkowicz

        Try something like this:

        set @str = 
        ' select AstId 
          from UserTable 
          where UserId = ''' + @UserId 
          + ''' and Password = ''' + @Password + ''''
        
        V Offline
        V Offline
        veereshIndia
        wrote on last edited by
        #3

        Hi, Thanks sir.I got It. Veeresh

        i want to join this group

        V 1 Reply Last reply
        0
        • V veereshIndia

          Hi All Iam getting error on executing this procedure Alter procedure LogProc ( @UserId varchar(500), @Password varchar(500) ) as declare @str varchar(500) set @str='select AstId from UserTable where UserId='+@UserId+'and Password='+@Password exec (@str); exec LogProc 'uname','xyz'; Server: Msg 170, Level 15, State 1, Line 1 Line 1: Incorrect syntax near 'Password'.

          i want to join this group

          J Offline
          J Offline
          Joe 2
          wrote on last edited by
          #4

          veereshIndia wrote:

          set @str='select AstId from UserTable where UserId='+@UserId+'and Password='+@Password exec (@str);

          :confused: You can eliminate 'Set' and 'exec (@str)' statements by having the select query alone which will get the records of the appropriate user. select AstID from userTable where userid = @userid and password = @password

          1 Reply Last reply
          0
          • V veereshIndia

            Hi, Thanks sir.I got It. Veeresh

            i want to join this group

            V Offline
            V Offline
            veereshIndia
            wrote on last edited by
            #5

            Hi Sir, Once again iam getting this error.Iam very new to Sql .Can please tel me how to use single quotes in query.Also giv me some help to this query Alter procedure LogProc ( @UserId varchar(500), @Password varchar(500) ) as declare @str1 varchar(500) declare @str2 varchar(500) set @str1 = ' select AstId from UserTable where UserId = ''' + @UserId + ''' and Password = ''' + @Password + '''' exec (@str1); set @str2=' select RoleId from AstProf where AstId = ' + @str1 exec(@str2); exec LogProc 'veeresh','veeresh' Iam getting this error (1 row(s) affected) Server: Msg 156, Level 15, State 1, Line 1 Incorrect syntax near the keyword 'select'.

            i want to join this group

            R 1 Reply Last reply
            0
            • V veereshIndia

              Hi Sir, Once again iam getting this error.Iam very new to Sql .Can please tel me how to use single quotes in query.Also giv me some help to this query Alter procedure LogProc ( @UserId varchar(500), @Password varchar(500) ) as declare @str1 varchar(500) declare @str2 varchar(500) set @str1 = ' select AstId from UserTable where UserId = ''' + @UserId + ''' and Password = ''' + @Password + '''' exec (@str1); set @str2=' select RoleId from AstProf where AstId = ' + @str1 exec(@str2); exec LogProc 'veeresh','veeresh' Iam getting this error (1 row(s) affected) Server: Msg 156, Level 15, State 1, Line 1 Incorrect syntax near the keyword 'select'.

              i want to join this group

              R Offline
              R Offline
              riyam hussain mm
              wrote on last edited by
              #6

              Try the query within a bracket () while assigning it with set keyword. i am not sure try it.

              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