Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2004-03-21
4
Medium Priority
?
328 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 1000 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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

Recently we ran in to an issue while running some SQL jobs where we were trying to process the cubes.  We got an error saying failure stating 'NT SERVICE\SQLSERVERAGENT does not have access to Analysis Services. So this is a way to automate that wit…
This month, Experts Exchange sat down with resident SQL expert, Jim Horn, for an in-depth look into the makings of a successful career in SQL.
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.

963 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