Q:

Column names in each table must be unique. Column name 'MntNeto' in table 'CONSUMO.DBO.ARCHIVOBOL082017' is specified more than once

I need to create column: 'MntNeto' with a default value of '0', 'Not Null'
only if it does not exist in the table CONSUMO.DBO.ARCHIVOBOL082017
In Sql Server Query Analizer this string works fine, every time:
if not exists (select * from syscolumns where id=object_id('CONSUMO.DBO.ARCHIVOBOL082017') and name='MntNeto') alter table CONSUMO.DBO.ARCHIVOBOL082017 add MntNeto money default 0 not null

request.cookies("usa_bd") value is the name of the table, in this case: CONSUMO.DBO.ARCHIVOBOL082017
<%
set conn=server.createobject("adodb.connection")
 '********************************************
 'CONNECTION STRING **************************
%>
<!--#include file="xxxxx.asp"-->
<%
 '********************************************
 '********************************************
conn.open vamos

sqlstring = " if not exists (select * from syscolumns " &_
            " where id=object_id('" & trim(ucase(request.cookies("usa_bd"))) & "') and name='MntNeto') " &_
            " alter table " & trim(ucase(request.cookies("usa_bd"))) & " add MntNeto money default 0 not null"
            response.write sqlstring & "<br><br>"
Set RS = Conn.Execute(sqlstring)

conn.close
set conn = nothing
%>

From asp it will create the column only if it does not exist.
If it does i got this error:
Column names in each table must be unique. Column name 'MntNeto' in table 'CONSUMO.DBO.ARCHIVOBOL082017' is specified more than once.
From Sql Query analyzer it works everytime with no problems, though.

A:

The only way I know this could be happening is if your connection in your dot net app is NOT pointing to the CONSUMO database as its initial catalog.   Therefore it's consulting the syscolumns table in the wrong database.
You will get the same error in SSMS if you change the connection of your query window to a different database.   At least, I do.

