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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T19:36:42+00:00 2026-05-14T19:36:42+00:00

I am trying to execute the following query. I don’t have ‘CrewID’ column so

  • 0

I am trying to execute the following query. I don’t have ‘CrewID’ column so in that case it will by pass update part of the script. but it gives error Invalid object CrewID’. Can you please tell me why it excute update part even my if condition does not matched. Is there is another way to do the same. I have the requirement where need to rename the column but before rename i have to copied data in other column and need to excute script many times.

if exists (select * from syscolumns where name ='CrewID' and id in (select id from dbo.sysobjects where id = object_id(N'[dbo].[WorkPlanAssignees]') and OBJECTPROPERTY(id, N'IsUserTable') = 1))
BEGIN   
update A set A.TempCrewID=B.ID from WorkPlanAssignees A inner join Crew B on A.CrewID=B.ID
END
  • 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-05-14T19:36:42+00:00Added an answer on May 14, 2026 at 7:36 pm

    SQL is not executed line by line. It’s compiled as a batch. At compile time, the column does not exists. So it gives an error. The IF is irrelevant.

    Use dynamic SQL or let us know what you’re trying to do.

    And asked before:

    Stored Procedure consist Add column, Update data for that column, and Select all data from that table

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

Sidebar

Related Questions

I'm trying to execute the following query but I receive a runtime error stating
I am trying to execute the following query: INSERT INTO table_listnames (name, address, tele)
I have a query that I want to execute that fastest possible. Here it
I'm using LINQ-to-Entities. Using the following query: var x = from u in context.Users
Please help me, I don't know what can be wrong with the following code:
I have the following form, which I have reduced as much as I can,
I've come across a query in an application that I've inherited that looks like
I'm trying to SELECT from the dba_tab_cols view from within a stored procedure. It's
I'm trying to check if a result in my DQL is NULL. I got

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.