Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Conditional Query

Author  Topic 

khanewal
Starting Member

33 Posts

Posted - 2010-08-19 : 21:06:29
TABLE:
1 A B C HIG
2 C D E RED
3 D E F RED
4 I J K HIG

Conditional Query:

IF COLUMN5 = 'HIG'
INSERT INTO (COL1, COL2, COL3)
ELSE
INSERT INTO (COL1,COL2,COL3)

Can you please let me know how I will implement this query in SQL Server

vaibhavktiwari83
Aged Yak Warrior

843 Posts

Posted - 2010-08-20 : 03:30:38
You are trying to insert into which table and what values ?

Vaibhav T

To walk FAST walk ALONE
To walk FAR walk TOGETHER
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2010-08-20 : 04:19:23
INSERT AuxiliaryTable (Col1, Col2, Col3
SELECT Col2, Col3, Col4 FROM Table WHERE Col5 = 'HIG'

INSERT AnotherAuxiliaryTable (Col1, Col2, Col3
SELECT Col2, Col3, Col4 FROM Table WHERE Col5 <> 'HIG'




N 56°04'39.26"
E 12°55'05.63"
Go to Top of Page
   

- Advertisement -