well they are conserned with the data that is being imported.
They only seem to be interesed in the schema ( at least that is all I
hear)
exact words.
this data is from 2 other databases, merge it and then insert it into
the 3rd database.
Well I can't insert reals into ints
ok then change the destination to hold our values.
BUT DO NOT CHANGE THE SCHEMA
I really am not sure why they keep sying that in such a stern way.
I had them faint when I said how do I remove your data without
changing the keys and then putting them back.
UH there are ways.
They seem to know everything but when I ask how you do something they
just say are you done yet
yep all I lack is finishing up LOL
I did what you said and then just cut and paste the names into excel
then put it all together in textpad
alter table dbo.ClientData
alter table dbo.ClientData ALTER COLUMN [CurrentWorkStatus]
nvarchar(50) NULL (one line...sorry this post is word wrapped funny)
one line for each column.
sure its 50 lines long but it works very well...
thank you all for the tip
On Fri, 30 Mar 2012 17:06:05 -0400, "Bob Barrows"
Post by Bob BarrowsPost by sparksI have about 100 columns in a table that I am inserting into another
table.
Most of them require reformatting of the destination.
something like
alter table dbo.ClientData
ALTER COLUMN [CurrentWorkStatus] nvarchar(50) NULL
but I have 50 that need to be updated
with a list of all of them is there a way to automate all 50 at once?
another 50 that need to be changed from tinyint to nvarchar(20)
things like that.
Why?
Heck if I know that is what they want to do.
(they have this super new database that is in production and they want
to import Everything from 2 others into it)
square peg in round hole type of thing
Wait a minute ... I thought you said the destination had the "approved"
schema ... why do you need to modify the destination schema?
You've just confused me.
Anyways, you can insert your list of column names and desired datatypes into
a table.
CREATE TABLE ColumnChanges (
ColName varchar(250), DataTypeChg varchar(50));
INSERT ColumnChanges
VALUES
('CurrentWorkStatus', 'nvarchar(50) NULL'),
('Col2', 'nvarchar(50) NULL'),
...
('ColN', 'nvarchar(50) NULL')
You can use Excel to help generate those row constructors (that's what the
value pairs in the parentheses are called).
Once the column names and datatype changes are inserted, you can use this
SELECT 'ALTER TABLE dbo.ClientData ALTER COLUMN ' +
ColName + ' ' + DataTypeChg + ';' As Statements FROM ColumnChanges
Run the query, copy the statements from the result window into a new query
window and run them.