0

Using SQL Server 2005

I want to insert a table with where condition

Table1 column Name - ID, Name, Dept, Rank

Query

Insert into table1 values('1', 'Raja' 'IT', 'True') where Rank <> 'False'

Need Query Help

1
  • Use an UPDATE statement instead of INSERT Commented Feb 22, 2010 at 4:41

2 Answers 2

3
insert into table 1 select '1', 'raja', 'it', 'true' from SomePlaceWhereRankExists where rank <> 'false'

It's not clear where 'Rank' is coming from in your pseudo code.

Sign up to request clarification or add additional context in comments.

Comments

0

Perhaps you're attempting something along the lines of:

IF @rank <> 'false'
  Insert into table1 values('1', 'Raja' 'IT', 'True')

You're not particularly clear about your goal however. Are you trying to update existing records or insert new ones? If you're inserting new ones, what are you trying to achieve using a where clause?

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.