×


Category: SQL Issues and Solutions


Executing queries from the MySQL Command Line

This article will guide you on how to run queries from the 3MySQL command line. The MySQL #Command Line Tool is a useful way to run #queries from the command line. It’s easy to run select queries and display the results in either a horizontal or vertical format, and the queries run are kept in a history file which you can navigate through. 

If you don't want to run a particular query after all you can use the c command to clear it.

The most common way to get a list of the MySQL #databases is by using the mysql client to connect to the MySQL server and run the SHOW DATABASES command. If you haven't set a password for your MySQL user you can omit the -p switch.

To Connect to a MySQL Database:

1. Click Services tab.

2. Expand the Drivers node from the Database Explorer.

3. Enter User Name and Password.

4. Click OK to accept the credentials.

5. Click OK to accept the default schema.

6. Right-click the MySQL Database #URL in the Services window.


SQLSTATE42000 syntax error or access violation

This article will guide you on methods to resolve 'sqlstate42000 #syntax error or access violation' which occurs due to wrong syntax entry or extra space or no space in the user's #SQL #query. 

The #1064 error displays any time you have an issue with your SQL syntax, and is often due to using reserved words, missing data in the database, or mistyped/obsolete commands.

As you can see there is more than one cause for the 1064 error within MySQL code. Now, you know how to correct the issues with your SQL Syntax, so your query can run successfully. This list will be updated as more specific instances are reported.


Restore a database in Alwayson Availability Group

This article will guide you on steps to restore a #database in alwayson availability group.

If you receive an #error that the database is in use, try to set the user to single user mode: USE master; GO ALTER DATABASE Database_name SET SINGLE_USER WITH ROLLBACK IMMEDIATE; Then try the restore with #recovery command again. Also, make sure you are on the latest service pack or cumulative update.

Creating a #SQL #Server AlwaysOn Availability Group.

Open SQL Server Management Studio and connect to the SQL Server instance. Expand the AlwaysOn High Availability folder in the Object Explorer. Right-click on the Availability Groups folder and select the New Availability Group Wizard.

To Restore a Database in a SQL Server AlwaysOn Availability Group:

1. Make the secondary server from which the backups were taken the primary server.

2. Remove the database to be restored from the AlwaysOn Availability Group.

3. Restore the database.

4. Add the database back into the Always Availability Group.


Configure Reporting Services in SQL Server

The article will guide you on the steps to follow to configure #reporting services after renaming the #SQL server. Also , you will learn how to rename the SQL server instance. 

To Configure #Report Server After Renaming SQL Server #Instance:

1. Go to #Database Setup page. 

2. Enter SQL Server name in Server Name and then click Connect. 

3. If Reporting Services is configured using the server name, you must update the database connection information whenever the server name is changed.

To change the service account for SQL Server Reporting Services:

i. Open Reporting Services Configuration Manager, and then connect to the instance of SQL Server Reporting Services.

ii. Click #Microsoft service Identity on the left pane.

iii. Change the account and the password in the Account text box and the Password text box, and then click Apply.


Database version or build from backup file

This article will guide you on how to determine the database #version or build from a #backup file.
To know what #SQL version a #database is:
The first is by using either Enterprise Manager or SQL Server Management Studio and right clicking on the instance name and selecting Properties. In the general section you will see information such as on the following screenshots. The "Product version" or "Version" gives you a number of the version that is installed.
In order to find the SQL Server version from a bak file:
1. Here is the output returned by the RESTORE HEADERONLY statement. Here you will see a DatabaseVersion column that contains the value.
2. That's how you find out from which version of SQL Server a given backup file came.


Improve SQL Server Bulk Data Import Performance

This article will guide you improve #bulk #data #import #performance. The BULK INSERT command is much faster than bcp or the data pump to perform text file import operations, however, the BULK INSERT statement cannot bulk copy data from #SQL Server to a data file. Use the bcp utility instead of DTS when you need to export data from the SQL Server table into a text file.
To Speed up SQL Bulk Insert with #transactions:
1. Declare the variables that store the number of desired items ( @items ), the size of the chunks( @chunk_size ) and the counter of the number of executed inserts( @counter )
2. Open the first transaction and initialize the while loop.