Solved

how to force a default value for a field during DTS import

Posted on 2004-03-21
4
307 Views
Last Modified: 2013-11-30
Hello,
Using DTS, I am creating a table(B) that I am importing in as another(A).  in table B, I do not have a field that is necessary for table A.  SO, I have created:

CREATE TABLE [XP].[dbo].[pin0030] (
[ACCOUNTNUM] int NOT NULL,
[ACCOUNTSTAT] varchar (1) NULL,
[LASTNAME] varchar (16) NULL,
[FIRSTNAME] varchar (16) NULL,
[MIDDLENAME] varchar (3) NULL,
[ENROLLED] varchar (4) NULL,
[GR] smallint NULL,
[SECTION] varchar (4) NULL,
[HM] varchar (6) NULL,
[KEYPAD] varchar (6) NULL,
[key_field] varchar (4) NULL,
[mergedate] timestamp NULL,
[Remote_Eml] smallint (2) NULL,
[Remote_Sta] varchar (4) NULL
)
where ENROLLED = '0030' and ACCOUNTSTAT = 'A'

the issue is that I need to somehow place a default value into the [key_field] which would = 'key'

I know that this is simple, but everything I try gives me an error in the DTS.  Thanks all for your help.
0
Comment
Question by:scg911
  • 2
4 Comments
 
LVL 34

Expert Comment

by:arbert
ID: 10644653
Couple ways....

Instead of using a source table, base the input on a query and "select" the value you want for the default and then you have the column to populate your destination column.

You could also use an activex script to populate the default (slower).  Create a new transformation, choose activex as the transformation type and it would look something like this dtsdestination("key_field")="whatever".

You could also change the definition on the destination to have a default.  This would populate the field on the load and then you could remove the default after wards.


Brett
0
 
LVL 75

Accepted Solution

by:
Anthony Perkins earned 250 total points
ID: 10644665
ALTER TABLE [XP].[dbo].[pin0030] ADD
      CONSTRAINT [DF_pin0030_key_field] DEFAULT ('key') FOR [key_field]

Also, please maintain these very old open questions:
1 12/16/2003 500 Server 2003 "stuck" at applying computer...  Open Operating Systems
2 09/30/2003 500 duplicate record, but not necessarily du...  Open Microsoft SQL Server
0
 

Author Comment

by:scg911
ID: 10644700
acperkins,

Thanks for your help, but I am trying to utilize the above create, and just be able to add some more code to the line below to make 'key' be the default value for [key_field]

[key_field] varchar (4) NULL,

also, the very old open questions, should have been closed out and under my login they all show PAQ
again, thanks for your help

scg911
0
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 10644761
>>just be able to add some more code to the line below to make 'key' be the default value for [key_field]<<
Since you have awarded me the points is this question now resolved?

>>under my login they all show PAQ<<
Thanks you for closing that one question, But I believe you may have oerlooked this one:
12/16/2003 500 Server 2003 "stuck" at applying computer...  Open Operating Systems
http://www.experts-exchange.com/Operating_Systems/Q_20827414.html
0

Featured Post

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction In my previous article (http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/SSIS/A_9150-Loading-XML-Using-SSIS.html) I showed you how the XML Source component can be used to load XML files into a SQL Server database, us…
In this article we will learn how to fix  “Cannot install SQL Server 2014 Service Pack 2: Unable to install windows installer msi file” error ?
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question