Reputation: 11992
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
Upvotes: 0
Views: 199
Reputation: 8595
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?
Upvotes: 0
Reputation: 21108
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.
Upvotes: 3