Error: Incorrect syntax near the keyword ‘top’
Description: Syntax error.
Incorrect syntax near the keyword ‘top’
select col top 1 * from table1
Incorrect syntax near the keyword ‘from’
select top 1 from table1
Solution: Correct the syntax.
select top 1 * from table1
Error: In order to run a trace against SQL Server you must be a member of sysadmin fixed server role or have the ALTER TRACE permission.
Description: When try to run the SQL Server Profiler using less privileged or minimal permissions credentials, this exception throws.
Solution: Provide ALTER TRACE permission for the particular user. Other ways are by providing, the user sysadmin fixed server role access which is not advised unless required.
GRANT ALTER TRACE TO user1
REVOKE the access
REVOKE ALTER TRACE FROM user1
Another way to grant rights, login with sysadmin login then open SSMS
~~ Open Security then Logins
~~ Right click on the login name and click Properties
~~ Securables tab
~~ Click Search to Select the instance that required permissions
~~ Under Explicit tab
~~ Select the check box ALTER trace permission and Click OK.
Error: Must declare the scalar variable “”.
Description: An SQL Server exception which occur when a local variable being used within a script, function or Stored Procedure that is not declared using the DECLARE statement.
Solution: Declare the variable using the DECLARE statement.
DECLARE @FirstName NVARCHAR(25);
Error: Object cannot be cast from DBNull to other types.
Description: An invalid cast exception, when trying to convert a nonexistent value of table column to other types.
Solution: Use DBNull.Value to validate the column having a valid value or not.
Error: The build must be stopped before the solution can be closed.
Description: When attempt to close Visual Studio solution or project while the build is running the exception windows throws up.
Solution: First stop the build or kill the process devenv.exe (if the solution got crashed) and then close the solution.
Error: Unable to connect to the Database.
Description: While trying or establishing a database connection and the connectivity to the database is not configured properly then this error occurs. More exception details as followed.
Exception Message: A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 – Error Locating Server/Instance Specified) (-1)
- Check whether TCP/IP in SQL Server Configuration is enabled or not.
- Ping the server name from command prompt. If no reply from server, then network connection to the server should be configured or enabled.
- Using Telnet command, we can check the port is opened or not, if not open the port.
- Check whether firewall is blocking the server port.
- Check any antivirus is blocking the server.
- Check the database name, user name and password using is correct or not.
- Check the required SQL Services (SQL Server Browser etc) account are running or not.
- Check your LAN network having connectivity issues.
- Use port number along with data source. e.g server name/server name, port number.
- Try creating alias in SQL Server Configuration.
- Try to connect the database through Visual Studio.
- Try using Database Server IP address as Server Name with or without port number.
Error: 404 – File or directory not found. The resource you are looking for might have been removed, had its name changed, or is temporarily unavailable.
Description: An HTTP Internal Server error thrown by Internet Information Services (IIS) when requested for an ASP.NET or ASP page etc. This can be of many reasons like, file or file path trying to access does not exists, or file name got renamed, the Virtual Directory wrongly mapped etc.
Solution: Check the file trying to access exists or not in correct path or location. Check the file path configured or able to access correctly. Check the Virtual Directory configured correctly and proper permissions given. Check the files extensions etc.