Skip to content
Advertisement

Can I add named computed columns in access sql query?

I need to make a stored procedure from SQL Server work in Access, and I am having a serious issue. When I try to run this query in Access, it asks me for a parameter named LNA, even when the value for the column is provided in the query. If I remove the name from the column, the query works fine, but I need this column to have a name so I can access it from a .NET program. Can I name a computed column in a SQL Query in Access?

SELECT [IdCatalogo],
       [IDARTICULO],
       [ncm],
       LNA=iif(isnull(L.posicion),'*','')
FROM [catarticulos] as c
    left join LNAPosicionesRes5 L on L.posicion = c.ncm
WHERE ([IdCatalogo] = @IdCatalogo)

Advertisement

Answer

I’m not sure if MS Access supports the = syntax. The normal way of doing this uses as:

SELECT [IdCatalogo], [IDARTICULO], [ncm],
       iif(isnull(L.posicion), '*', '') as LNA
FROM . . .
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement