SQLTeam.com | Weblogs | Forums

Host_Name() in column default value not correctly value


Hi all
when i use SELECT HOST_NAME() in query editor the result is the host name of client this is true result

but when i put HOST_NAME() as default value of column the result value i server name not client this is false value
i want client host name not server host name in default value of column

thanks all


How and Where do you execute the Query to insert the record into the table ?


column default value in design

	DF_dbo_ERP_Taxs_CT_UserHostName DEFAULT Host_Name() FOR UserHostName


i mean where is the client application excute ? Is it on the same machine as the SQL Server ? or a separate PC ?

Try perform a INSERT to the table in the Query Window. Does it also show the correct host name ?


from my machine
open SQL Server 2014 Management Studio
connect to other PC having my database

open new query in my database
the result is MALI [my pc name]

in the same session open my table and insert new row manual . the result of default value of my column is ERPSERVER [server name having my database]


is there any trigger on that table ? Check the trigger


Thanks Khatn.
There is no trigger, the problem was in CDC system.
the default value of column in CDC table that execute the even from server not client server.
when i try to do host_name in default column in my table not CDC table it works fine
Note: CDC = Change Data Capture.
thanks you.