-2

I used mvn , build tool to build my project. my sql server is MSSQL2017 . but when I , build project, it failed, given like this error. need some exptert help to fix it.

    [INFO] Creating database: DatabaseConfiguration[host=CWLK-UMAYANGA,port=1433,user=spider3,password=********,catalog=schema-export_180427_083129335
[DEBUG] Executing: cmd.exe /X /C "sqlcmd -S tcp:CWLK-UMAYANGA,1433 -d master -U spider3 -P spider3 -I -r -Q "DECLARE @data_path nvarchar(256);SET @data_path = (SELECT SUBSTRING(physical_name, 1, CHARINDEX(N'master.mdf', LOWER(physical_name)) - 1)FROM master.sys.master_files WHERE database_id = 1 AND file_id = 1);EXEC ('CREATE DATABASE [schema-export_180427_083129335] ON ( NAME = MAIN, FILENAME = ''' + @data_path + 'schema-export_180427_083129335.mdf'', SIZE = 5MB ) LOG ON ( NAME = LOG, FILENAME = ''' + @data_path + 'schema-export_180427_083129335.ldf'', SIZE = 1MB)')""
'sqlcmd' is not recognized as an internal or external command,
operable program or batch file.
[ERROR] The following errors occured during execution:
[ERROR] 'sqlcmd' is not recognized as an internal or external command,
[ERROR] operable program or batch file.
[DEBUG] Received event (class org.apache.maven.lifecycle.internal.DefaultExecutionEvent): org.apache.maven.lifecycle.internal.DefaultExecutionEvent@638e271a

I type this query {"sqlcmd -S tcp:CWLK-UMAYANGA,1433 -d master -U spider3 -P spider3 -I -r -Q "DECLARE @data_path nvarchar(256);SET @data_path = (SELECT SUBSTRING(physical_name, 1, CHARINDEX(N'master.mdf', LOWER(physical_name)) - 1)FROM master.sys.master_files WHERE database_id = 1 AND file_id = 1);EXEC ('CREATE DATABASE [schema-export_180427_083129335] ON ( NAME = MAIN, FILENAME = ''' + @data_path + 'schema-export_180427_083129335.mdf'', SIZE = 5MB ) LOG ON ( NAME = LOG, FILENAME = ''' + @data_path + 'schema-export_180427_083129335.ldf'', SIZE = 1MB)')" } in command prompt , it appear as following image and nothing given any error message.

enter image description here

uma
  • 1,477
  • 3
  • 32
  • 63
  • 1
    Regarding your recent edit which is hard to understand due to the typo "it appear like this. nothing aivenany error message" ... So if there's no error message, it probably worked...did you check? – Richardissimo Apr 28 '18 at 04:10
  • 1
    @feelingunwelcome That question was specifically for the 'mvn.bat' file (part of maven). This user is able to run 'mvn', but it's complaining that it can't find 'sqlcmd' (not part of maven, part of SQL server). So I don't think these questions are duplicates. – Richardissimo May 01 '18 at 22:16
  • 1
    @uma Did you check whether it had created your database, since there were no errors? (You may need to press Refresh in SqlServerMgmtStudio if you had already displayed the list of databases.) – Richardissimo May 01 '18 at 22:19
  • My question is not "https://stackoverflow.com/questions/32706000/error-in-maven-build-mvn-bat-not-recognized" this. m mvn command working properly. @Richardissimo correct , t is about 'sqlcmd' – uma May 03 '18 at 00:03

1 Answers1

1

The error message means that it cannot find sqlcmd in any of the folders in the Environment's "Path" variable for the user who the build is executing as.

I would definitely suggest specifying the file extension to sqlcmd, so it doesn't have to guess, and to avoid ambiguity.

If that doesn't fix it, then either specify the full path to sqlcmd in your build, or modify the "Path" environment variable for that user to include the folder which contains sqlcmd.

You could add cmd.exe "set path" into your build to make it show the value in the path variable.

Richardissimo
  • 5,596
  • 2
  • 18
  • 36
  • I try to find such like file insider my MSSQL Server(2017) instalation , 140/tools/bin ,directory ,but not file such that. ? – uma Apr 28 '18 at 00:51
  • 1
    @uma If you can't find it, either check the SQL installation features, and switch on the one containing command line utilities, or install it independently by [downloading from Microsoft](https://www.microsoft.com/en-us/download/details.aspx?id=53591) (this link may or may not be suitable for your installation, so check which version you need before downloading). – Richardissimo Apr 28 '18 at 04:01
  • I will try above solution again.and give feed back. – uma May 03 '18 at 00:05