views:

303

answers:

2

I have a sql server pass-thru query like this:

*select * into myTable from openquery (yourComputer, 'select x,y,z, from yourTable')*

The problem is the columns in myTable are defaulting to not null and I will later want to add rows to this table with some columns null.

Can I get round this?

A: 

you could insert the results into a temp table and then update the table to set all null values to '', then insert the values in the temp table to the actual table

DForck42
+1  A: 

Create myTable before inserting data, then perform insert.

create table myTable (
    x int null,
    y int null,
    z int null
)
go
insert into myTable (x, y, z)
select x, y, z
from openquery (yourComputer, 'select x,y,z, from yourTable')
Arvo
This would work. It's just that x,y,z is actually a big long list of all kinds of data types, so I was hoping there would be some way of overriding the default
cindi
I found one script on experts-exchange (at bottom of page): http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/Q_24022393.html, maybe helps.
Arvo