By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,660 Members | 1,593 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,660 IT Pros & Developers. It's quick & easy.

Subqueries are not allowed in this context. Only scalar expressions are allowed.

P: 79
I am writing this query but didnt understand why isnt it working...
Its giving me the error :
Subqueries are not allowed in this context. Only scalar expressions are allowed.
Expand|Select|Wrap|Line Numbers
  1. INSERT INTO [Job] ([User_Id], [Cat_id], [Job_Description], [Job_Status], [JobTitle], [NumberOfPositions], [JobTenure], [ManagementLevel], [JobDuration], [EducationRequired], [Experience], [RequiredTravel], [Salary], [StartDate], [CoverLetterRequirement], [ContactPerson], [EmailAddress], [Closing Date CV], [EmployerName], [EmployerPersonalEmail], [EmployerPhone])
  2. VALUES ((select ([Job].User_Id) as UserID from Job
  3. inner join Users ON ([Job].User_Id = [Users].User_Id)
  4. where [Job].User_Id = '1') , @Cat_id, @Job_Description, @Job_Status, @JobTitle, @NumberOfPositions, @JobTenure, @ManagementLevel, @JobDuration, @EducationRequired, @Experience, @RequiredTravel, @Salary, @StartDate, @CoverLetterRequirement, @ContactPerson, @EmailAddress, @Closing_Date_CV, @EmployerName, @EmployerPersonalEmail, @EmployerPhone)
Jan 12 '10 #1
Share this Question
Share on Google+
3 Replies

Expert 2.5K+
P: 2,878
I assume your SELECT will only return a single record. Try this:

Expand|Select|Wrap|Line Numbers
  3. INSERT INTO [Job] ([User_Id], [Cat_id], [Job_Description], [Job_Status], [JobTitle], [NumberOfPositions], [JobTenure], [ManagementLevel], [JobDuration], [EducationRequired], [Experience], [RequiredTravel], [Salary], [StartDate], [CoverLetterRequirement], [ContactPerson], [EmailAddress], [Closing Date CV], [EmployerName], [EmployerPersonalEmail], [EmployerPhone])
  4. select ([Job].User_Id) as UserID, @Cat_id, @Job_Description, @Job_Status, @JobTitle, @NumberOfPositions, @JobTenure, @ManagementLevel, @JobDuration, @EducationRequired, @Experience, @RequiredTravel, @Salary, @StartDate, @CoverLetterRequirement, @ContactPerson, @EmailAddress, @Closing_Date_CV, @EmployerName, @EmployerPersonalEmail, @EmployerPhone 
  5. from Job inner join Users ON ([Job].User_Id = [Users].User_Id)
  6. where [Job].User_Id = '1'
Happy Coding!!!

~~ CK
Jan 12 '10 #2

P: 79

Sorry my information mislead you ... My mistake... Sorry for that..

I have two tables one is the "HOST" through which I am going to get the userID and the other is the "JobCategory" from which I am going to get a job_CategoryID... And the rest of the values are going to come from the aspx form.
I want to insert all the values from the form except the hosts User_ID and Job Category cateogryID, so that I could insert it directly.
The table I am using to insert the information is the JOB table..

Can you please help me with that...

Thanks in advance


Syed Ahmed Hussain
Jan 15 '10 #3

Expert 2.5K+
P: 2,878
Could you post the structure of your tables or sample data and identify which data would be coming from where?

Happy Coding!!!

~~ CK
Jan 20 '10 #4

Post your reply

Sign in to post your reply or Sign up for a free account.