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. Problem in query

Problem in query

Scheduled Pinned Locked Moved Database
helpdatabasetutorial
5 Posts 3 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.
  • U Offline
    U Offline
    uspatel
    wrote on last edited by
    #1

    ALTER PROCEDURE [dbo].[insert_task_details11]
    @taskname varchar(150),
    @completiondate varchar(30)

    AS
    BEGIN
    DECLARE @DataID int
    select DataID=MAX(taskid) from tblTaskAssign;
    insert into tblJobs (taskid,taskname,completiondate) values (DataID,@taskname,@completiondate)
    END

    I want to insert maximum taskid into tblJobs. It gives Error The name "DataID" is not permitted in this context. Valid expressions are constants, constant expressions, and (in some contexts) variables. Column names are not permitted. and if I use @DataId instedat od DataID, null value goes in taskid in tblJobs. How to solve this problem thanks

    _ B 2 Replies Last reply
    0
    • U uspatel

      ALTER PROCEDURE [dbo].[insert_task_details11]
      @taskname varchar(150),
      @completiondate varchar(30)

      AS
      BEGIN
      DECLARE @DataID int
      select DataID=MAX(taskid) from tblTaskAssign;
      insert into tblJobs (taskid,taskname,completiondate) values (DataID,@taskname,@completiondate)
      END

      I want to insert maximum taskid into tblJobs. It gives Error The name "DataID" is not permitted in this context. Valid expressions are constants, constant expressions, and (in some contexts) variables. Column names are not permitted. and if I use @DataId instedat od DataID, null value goes in taskid in tblJobs. How to solve this problem thanks

      _ Offline
      _ Offline
      _Damian S_
      wrote on last edited by
      #2

      Uma Shankar Patel wrote:

      select @DataID=MAX(taskid) from tblTaskAssign; insert into tblJobs (taskid,taskname,completiondate) values (@DataID,@taskname,@completiondate)

      Should work assuming that there are TaskID's in tblTaskAssign.

      Silence is golden... but duct tape is silver!! Booger Mobile - My bright green 1964 Ford Falcon - check out the blog here!! | If you feel generous - make a donation to Camp Quality!!

      U 1 Reply Last reply
      0
      • _ _Damian S_

        Uma Shankar Patel wrote:

        select @DataID=MAX(taskid) from tblTaskAssign; insert into tblJobs (taskid,taskname,completiondate) values (@DataID,@taskname,@completiondate)

        Should work assuming that there are TaskID's in tblTaskAssign.

        Silence is golden... but duct tape is silver!! Booger Mobile - My bright green 1964 Ford Falcon - check out the blog here!! | If you feel generous - make a donation to Camp Quality!!

        U Offline
        U Offline
        uspatel
        wrote on last edited by
        #3

        values are inserted but in TaskId column Null value inserted in tblJobs table. i.e. DataId is not inserted or not fetched properly from tblTaskAssign to be inserted into tblJobs

        1 Reply Last reply
        0
        • U uspatel

          ALTER PROCEDURE [dbo].[insert_task_details11]
          @taskname varchar(150),
          @completiondate varchar(30)

          AS
          BEGIN
          DECLARE @DataID int
          select DataID=MAX(taskid) from tblTaskAssign;
          insert into tblJobs (taskid,taskname,completiondate) values (DataID,@taskname,@completiondate)
          END

          I want to insert maximum taskid into tblJobs. It gives Error The name "DataID" is not permitted in this context. Valid expressions are constants, constant expressions, and (in some contexts) variables. Column names are not permitted. and if I use @DataId instedat od DataID, null value goes in taskid in tblJobs. How to solve this problem thanks

          B Offline
          B Offline
          Blue_Boy
          wrote on last edited by
          #4

          try this

          DECLARE @DataID int
          set @DataID = (select isnull(max(taskid),0) from tblTaskAssign)

          insert into tblJobs (taskid,taskname,completiondate) values (@DataID ,@taskname,@completiondate)


          I Love T-SQL "VB.NET is developed with C#.NET" If my post helps you kindly save my time by voting my post.

          U 1 Reply Last reply
          0
          • B Blue_Boy

            try this

            DECLARE @DataID int
            set @DataID = (select isnull(max(taskid),0) from tblTaskAssign)

            insert into tblJobs (taskid,taskname,completiondate) values (@DataID ,@taskname,@completiondate)


            I Love T-SQL "VB.NET is developed with C#.NET" If my post helps you kindly save my time by voting my post.

            U Offline
            U Offline
            uspatel
            wrote on last edited by
            #5

            thanks

            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