sqlcmd runs into error while parsing my .sql file - sqlcmd

I am invoking sqlcmd as follows:
sqlcmd -S SERVERNAME\SQLEXPRESS -i "C:\Documents and Settings\user\Desktop\data\bigDB.sql"
And I get an error while the script is executing:
Sqlcmd: Error: Syntax error at line 86626 near command '%' in file 'C:\Documents
and Settings\user\Desktop\data\bigDB.sql'.
How do I tell sqlcmd to ignore the current record and keep running? I think i could edit bigDB.sql and include an :On Error Ignore directive at the top - but the bigDB.sql file is 5GB is size - i cant edit.
Or How could I go to the specific line and delete out the bad record? Thanks for helping.

Related

What does the symbol '<' mean on the mysql command line and where is the imported file saved?

I gather from the context of the following page https://github.com/AtomBoy/double-metaphone that the following command has something to do with adding a custom function to the mysql server. Here is the command that I don't understand:
mysql yourDataBaseName -u root -p < metaphone.sql
I successfully ran the command, and installed the function, however I'm still unclear on the complete function of the less than sign. I understand that I am importing a .sql file. In this case the sql file is a function.
Where is this function saved?

Creating a cron to execute a daily mysql dump

I want to create a cron job to execute the following mysql dump on a daily basis and save a csv file to a designated directory. However, I am trying to execute the command from my command line and it throws an error. I can't figure out what I am doing wrong.
mysql -u dom_hemma -ppasswordhere -D dom_hemma -e "SELECT * FROM `wp7f_posts` WHERE `post_type` LIKE 'flamingo_inbound' INTO OUTFILE '/home/domhemma/public_html/access/access.csv' FIELDS TERMINATED BY `,` LINES TERMINATED BY `\n`;"
I expect a csv file to be produced
Instead I get the "syntax error near unexpected token `('"
I think you have an error related to the quotation

ERROR 1231 (42000) with sql_mode when trying to import a sql dump in MySQL Workbench

I am trying to import a dump of a database to my localhost in MySQL Workbench.
At the moment of trying to import a dump of MySQL version 5.7 to a 8.0.14 version, I get this error:
ERROR 1231 (42000) at line 198: Variable sql_mode can't be set to the value of NO_AUTO_CREATE_USER
Operation failed with exitcode 1
The problem is that the dump has a size of 4GB and I can't open it beacause my PC freezes. Is there a form of remove this line or solve this problem?
You seem to have hit this MySQL 8.0 bug. The bug page says it's fixed in 8.0.13, but since you are using 8.0.14 and still meeting the problem, this might not be the case...
It also suggest a workaround : replace all instances of ,NO_AUTO_CREATE_USER with nothing. If you are not able to open the file with a text editor because it is too big, you can use Perl to update the file in place with a regular expression, like:
perl -pi -e 's/,NO_AUTO_CREATE_USER//g' file
Flags explanation:
-e causes the Perl code to be executed
-p means : execute the code for each file line
-i means : edit the file in-place

Unable to copy files using xcopy sqlcmd

I am copying files from one server to another through sqlcmd. I am able to get the output of the select statement, but am unable to copy. I am unable to find the syntax for copying files through sqlcmd xcopy.
H:\>sqlcmd -S cx-siscsqltest\sqlinst -Q "xcopy d:\sysdba\ e:\"
Msg 102, Level 15, State 1, Server CX-SISCSQLTEST\SQLINST, Line 1
Incorrect syntax near '\'.
I am able to get output of following:
H:\>sqlcmd -S cx-siscsqltest\sqlinst -Q "select * from sysaltfiles"
What is the xcopy sqlcmd syntax for copying files?

Executing Mass MySQL database restore from batch file using PowerShell

So what I have is about 80-90 MySQL DBs to restore and using < gives the 'saved for future use' error when used directly through PowerShell. The next step I tried was using just straight & cmd /c which also prompted the same error.
I tried the code below, but I get either Access Denied or 'system can't find the file specified' and I'm trying to figure out where it's messing up. Any help is definitely appreciated.
PowerShell
$list= gci "C:\Scripts\Migration\mysql\" -name
$mysqlbinpath="C:\Program Files\MySQL\MySQL Server 5.6\bin\mysql"
$mysqluser="admin"
$mysqlpass=getpass-mysql
pushd "C:\Program Files\MySQL\MySQL Server 5.6\bin"
foreach($file in $list){
$dbname=$file.Substring(0, $file.LastIndexOf('.'))
$location='C:\Scripts\Migration\mysql\'+$file
& $bt $mysqluser, $mysqlpass, $dbname, $location
write-host "$file restored"
}
The batch file called by $bt
Batch
"cmd /c "mysql" -u %1 -p%2 --binary-mode=1 %3 < %4"
getpass-mysql is a function I have that pulls the MySQL root pass (our root user is 'admin') as a string.
I hope this isn't a duplicate as I checked other posts first and tried those solutions (perhaps incorrectly applied) and they didn't seem to help.
I have updated the code block with the changes I have made. I am currently receiving the error about using the right syntax near ' ■-'.