Advertisement

03.31.2008 at 11:46AM PDT, ID: 23283523
[x]
Attachment Details

conditional SQL insert

Asked by samsation in MS SQL Server, MS SQL DTS

Tags: sql server 2000

I'm wondering if there's a way in SQL to transform the data that is transferred to a new table based on what data is found in a field of the source table.   In other words in the example below, if Custom_Source_Field contains "A6", I want to insert "Allowance 6 weeks" (instead of A6) into Custom_Target_Field.  If the source table contains "A9", I want to insert "Allowance 9 weeks" into the target table, etc.   Thanks for any help for this newbie question. Start Free Trial
1:
2:
3:
INSERT  INTO  Products(Product_ID, Name, SKU, Custom_Source_Field) 
SELECT  Product_ID, Name, SKU, Custom_Target_Field   
FROM  dbo.vwProductsUpdate
[+][-]03.31.2008 at 12:00PM PDT, ID: 21248083

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]03.31.2008 at 12:06PM PDT, ID: 21248122

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]03.31.2008 at 12:16PM PDT, ID: 21248205

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]03.31.2008 at 12:21PM PDT, ID: 21248250

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: MS SQL Server, MS SQL DTS
Tags: sql server 2000
Sign Up Now!
Solution Provided By: laneduncan
Participating Experts: 3
Solution Grade: A
 
 
[+][-]03.31.2008 at 12:22PM PDT, ID: 21248262

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 7-day free trial to view this Assisted Solution or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628