Home » SQL Server Error : 107, Severity: 15. The column prefix ‘%.*ls’ does not match

SQL Server Error : 107, Severity: 15. The column prefix ‘%.*ls’ does not match

  • by

SQL Server Error : 107 Details




SQL Server Error: 107
Severity: 15
Event Logged or not: No
Description:
The column prefix ‘%.*ls’ does not match with a table name or alias name used in the query.
Severity 15 Description:
Indicates syntax errors in the Transact-SQL command.

Reading sql server error log location from SQL Query

Identifying SQL Server Error Log File used by SQL Server Database Engine can be done by reading SQL Server Error Logs. DBA can execute the XP_READERRORLOG extended stored procedure to read the SQL Server Error Log and search for its location used by the instance of SQL Server.

USE master
Go
xp_readerrorlog 0, 1, N'Logging SQL Server messages in file', NULL, NULL, N'asc'
Go

The parameters for XP_READERRRORLOG are:
1. Value of error log file we would like to read. values are 0 = current, 1 = last one before current, 2 = second last before current etc…
2. Log file type:- 1 or NULL = error log, 2 = SQL Agent log
3. Search string 1:- String one you want to search for
4. Search string 2:- String two you want to search for to further refine the results
5. start time for Search
6. end time for search
7. Sort order for search results:- N’asc’ = ascending, N’desc’ = descending

By default, we have 6 Server Error Logs kept but we can increase the number of SQL Server Error Logs from the default value of six.

For other ways to read and find error log location please our artcile https://sqlserver-dba.co.uk/error-log/sql-server-identify-location-of-the-sql-server-error-log-file.html

Solution for Resolving the Error

An asterisk (*) in the query’s select list has been erroneously qualified with a column prefix. Under the following circumstances, this error can be returned:

The column prefix does not match any of the query’s table or alias names. The alias name (T1) is used as a column prefix in the following statement, however the alias is not declared in the FROM clause.

SELECT T1.* FROM dbo.ErrorLog;

When a table’s alias name is used in the FROM clause, the table name is used as a column prefix. The table name ErrorLog is used as the prefix in the line below; however, the table has an alias (T1) defined in the FROM clause.

SELECT ErrorLog.* FROM dbo.ErrorLog AS T1;

SELECT ErrorLog.* FROM dbo.ErrorLog AS T2;

 

Solution:

Match the column prefixes to the table or alias names supplied in the query’s FROM clause. For example, the following sentences can be corrected:

 

SELECT T1.* FROM dbo.ErrorLog AS T1;  

or

SELECT ErrorLog.* FROM dbo.ErrorLog; 

SQL Server Error Code and solution summary


SQL Server Error: 107
Severity: 15
Event Logged or not: No
Description:
The column prefix ‘%.*ls’ does not match with a table name or alias name used in the query.

Solution for this error is for using correct alias’s or using full table names while writing SQL Script or Code.

Leave a Reply

Your email address will not be published. Required fields are marked *