Using Sybase ASE 16
I have a table that uses a tsql function host_name() to provide a default column value:
CREATE TABLE exampleTable
(
id INT,
hostname VARCHAR(32) DEFAULT Host_name()
);
The table works and populates as it should. However, I want to BCP (bulk copy) all data in this table somewhere else in order to stage it for monitoring/reporting/etc. This will occur on many tables with a similar schema like this one.
My problem is as follows: After bcping to a different db on a different host, the default value of host_name() changes to reflect the CURRENT host it is residing on. Meaning, it's as if the bcp is passing the function host_name() itself, not the value it originally provided. I want the bcp to pass the default host_name() from the source instead.
Example: db1 has host 123. I want to bcp over the value 123 to another db, which has host 456. Instead, the bcp passes host_name() itself which will change all values of '123' in the transferred table to 456.
Thoughts?
I'm relatively inexperienced with BCP so I'm not sure if there's a command option that retains default values. I was also considering using CAST(host_name(), AS varchar(32))
to replace my current default value in the table above^
Otherwise, I was thinking I alter the insert statement that populates the table. It is currently very simple:
exec sp_monitorconfig 'number of open databases', exampleTable
This inserts the result set of a system stored proc into my table. I'm unsure how to alter this to insert host_name() or the value it produces.
Let me know if this makes sense.
Thanks
I have replaced host_name()
in my table schema with asehostname()
and my problem is solved. host_name()
was returning the name of the machine executing the bcp job every time, rather than the ASE host where the data is coming from.