it is about sybase Insufficient account permissions?
[sybiq#db ~]$ isql -U abc -P abc -S abc3
1> sp_spaceused
2> go
Msg 504, Level 11, State 0:
SQL Anywhere -265: 'sp_spaceused'
1> select ##version
2> go
##version
--------------------------------------------------------------------------------------------------------------------------------
Sybase IQ/15.4.0.3038/140813/P/ESD 4.5/Enterprise Linux64 - x86_64 - 2.6.18-194
.el5/64bit/2014-08-13 16:59:08
(1 row affected)
sp_iqspaceused command is ok。
that can not search from the internet.
Related
I have the following batch file and SQL script that runs several .sql files. Is there a way to log any errors and continue with script?
myautosql.sql
PRINT 'Starting...'
--:On Error exit
:r SQLQuery10.sql
:r SQLQuery20.sql
:r SQLQuery30.sql
PRINT 'Completed normally on ' + (CONVERT( VARCHAR(24), GETDATE(), 101))
GO
myautosql.bat
SQLCMD -E -d rstestdb1 -i myautosql.sql
PAUSE
When I intentionally raiseerror in the SQLQuery20.sql file the batch program stops. Is there a way for it to log the error and continue with script?
When you raiserror, the 2nd parameter severity dictates whether the query will continue to run or not. A severity of 0-10 are informational (no error is raised), 11-19 are non fatal errors, 20-25 will raise the error and then immediately terminate your connection to the database server. You must be a sysadmin to use a severity from 19-25.
I think this simulates what you are trying to do.
auto.sql
PRINT 'Starting...'
:r 1.sql
:r 2.sql
PRINT 'Completed normally on ' + (CONVERT( VARCHAR(24), GETDATE(), 101))
1.sql
select 1 as value
raiserror ('This will not stop execution', 11, 1)
select 2 as value
2.sql
select 3 as value
raiserror ('This is an information message, not an error', 10, 1)
select 4 as value
Then you run the following command to capture the query output to output.txt and informational/error messages to error.txt:
sqlcmd -E -d tempdb -i auto.sql -r1 >output.txt 2>error.txt
-r1 tells sqlcmd to redirect informational/error messages to STDERR.
>output.txt redirects STDOUT from the queries (including affected row counts) to a file called output.txt.
2>error.txt redirects STDERR to a file called error.txt.
Here are the two files from the above script:
output.txt
value
-----------
1
(1 rows affected)
value
-----------
2
(1 rows affected)
value
-----------
3
(1 rows affected)
value
-----------
4
(1 rows affected)
error.txt
Starting...
Msg 50000, Level 11, State 1, Server NAME, Line 4
This will not stop execution
This is an information message, not an error
Completed normally on 02/27/2020
HTH
I have a docker file where I import two databases.
FROM mcr.microsoft.com/mssql/server
RUN mkdir -p /var/opt/mssql/backup
COPY clean_SCManager.bak /var/opt/mssql/backup/SCManager.bak
COPY clean_SCServer.bak /var/opt/mssql/backup/SCServer.bak
COPY SCManager-setup.sql /var/opt/mssql/SCManager-setup.sql
COPY startup.sh /var/opt/mssql/startup.sh
ENV MSSQL_SA_PASSWORD=P#ssw0rd
ENV ACCEPT_EULA=Y
RUN chmod +x /var/opt/mssql/startup.sh
CMD /var/opt/mssql/startup.sh
EXPOSE 1433
Now I want to insert some values into one of my databases, for that I am using a SQL file which contains a INSERT INTO command.
USE SCManager;
GO
INSERT INTO epls_dbo.Account("uid", "login", "password_hash", "lastLogin", "failedLogins", "locked", "role", "locale", "accountPenIdUid")
VALUES (4294967306, 'sysadm', '2398ef2774cd07f31037e9347de3e660', '2017-09-12 14:50:35.607', 0, 'False', 'Admin', 'en_US', NULL);
This SQL will be called by a bash script, in this I am using sqlcmd to execute the SQL script.
#/bin/bash
echo "startup.sh is called, starting sqlserver"
/opt/mssql/bin/sqlservr &
echo "start sleeping for 20 seconds"
sleep 20
echo "sleeping done"
/opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P "P#ssw0rd" -Q "RESTORE FILELISTONLY FROM DISK = '/var/opt/mssql/backup/SCServer.bak'"
/opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P "P#ssw0rd" -Q "RESTORE FILELISTONLY FROM DISK = '/var/opt/mssql/backup/SCManager.bak'"
/opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P "P#ssw0rd" -Q "RESTORE DATABASE SCManager FROM DISK = '/var/opt/mssql/backup/SCManager.bak' WITH MOVE 'SCManager' TO '/var/opt/mssql/data/SCManager.mdf', MOVE 'SCManager_log' TO '/var/opt/mssql/data/SCManager_log.ldf'"
/opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P "P#ssw0rd" -Q "RESTORE DATABASE SCServer FROM DISK = '/var/opt/mssql/backup/SCServer.bak' WITH MOVE 'SCServer' TO '/var/opt/mssql/data/SCServer.mdf', MOVE 'SCServer_log' TO '/var/opt/mssql/data/SCServer_log.ldf'"
sleep 10
/opt/mssql-tools/bin/sqlcmd -S localhost -U SA -d SCManager -P "P#ssw0rd" -i "/var/opt/mssql/SCManager-setup.sql"
tail -f /dev/null
When I run the docker image I can see in the logs that the database has been imported and that the sql file has been executed but the sql has not been successfully executed
Changed database context to 'SCManager'.
Msg 207, Level 16, State 1, Server fb5db2041be5, Line 4
Invalid column name 'uid'.
Msg 207, Level 16, State 1, Server fb5db2041be5, Line 4
Invalid column name 'login'.
Msg 207, Level 16, State 1, Server fb5db2041be5, Line 4
Invalid column name 'password_hash'.
Msg 207, Level 16, State 1, Server fb5db2041be5, Line 4
Invalid column name 'lastLogin'.
Msg 207, Level 16, State 1, Server fb5db2041be5, Line 4
Invalid column name 'failedLogins'.
Msg 207, Level 16, State 1, Server fb5db2041be5, Line 4
Invalid column name 'locked'.
Msg 207, Level 16, State 1, Server fb5db2041be5, Line 4
Invalid column name 'role'.
Msg 207, Level 16, State 1, Server fb5db2041be5, Line 4
Invalid column name 'locale'.
Msg 207, Level 16, State 1, Server fb5db2041be5, Line 4
Invalid column name 'accountPenIdUid'.
When I connect to the running docker container I can query the database, so the database is available and the table which I want to insert into exits
root#fb5db2041be5:/# /opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P "P#ssw0rd" -d SCManager -Q "select * from epls_dbo.Account"
uid login password_hash lastLogin failedLogins locked role
locale accountPenIdUid
-------------------- ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -------------------------------- ----------------------- ------------ ------ ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ------ --------------------
(0 rows affected)
Also I can execute in the bash my insert into command an it inserts correctly the values, why does it not work by calling it from my bash script?
In some of my servers (not all of them), I get the following message inside sqlcmd:
========================================
PS C:\Users> sqlcmd -S 10.10.1.112 -U cheritia
Password:
1> select getdate()
2> go
2019-01-30 16:06:11.667
(1 rows affected)
1> ed
Sqlcmd: Error: Internal error at ExecProcess (Reason: The filename, directory name, or volume label syntax is incorrect).
========================================
In my typical installation, I use "vim" as an editor inside sqlcmd, I have tried other editors, they all fail.
The error is the same in powershell or Windows cmd.
Any clue?
I am trying to execute a stored procedure using this command line utility:
sqlcmd -m 1 -S inxcert -U user1 -P u8er1 -i "D:\ESP\RunSQL.sql" -h -1 -o "D:\ESP\testoutput.txt"
Following is what I have written in RunSQL.sql:
exec spc.load_tables
Though the stored procedure exist in the database, credentials are correct and SQL Server runs fine when run from SSMS I am getting the following error in the output file:
Msg 2812, Level 16, State 62, Server I0160SQL03\I0160SQL03, Line 1
Could not find stored procedure 'spc.mjr_vs_load_tables'.
Please help me to learn how to resolve the error.
Looks like it's executing against the default database (probably master) so not finding your procedure.
Try either adding:
USE [DBNAME]
to RunSQL.sql, or specifying:
-d DBNAME
to your sqlcmd parameters.
In Sql Server 2000, connected using osql command line, connected through a DSN ODBC, Using the OLEDB Provider, I am trying to export the result of a Stored Procedure to an XML file. However I get and error no matter how far down I simplify the query.
if I use the OUT qualifer I get the following error:
Msg 179, Level 15, State 1, Server SERVER, Line 1
Cannot use the OUTPUT option when passing a constant to a stored procedure.
which from my reading is expected. but no matter how I use QUERYOUT I get following error:
Msg 170, Level 15, State 1, Server SERVER, Line 1
Line 1: Incorrect syntax near 'queryout'.
Here is the simplest query I can muster and I still get this error:
bcp "Select * FROM [SERVER].[SCHEMA].[TABLE]" queryout \\fileserver\test.txt -c -T
You need to create a text file such as
set nocount on
select * from table
and save it. Let say it is in c:(input_text).txt
Then, in SQL server management studio, create and run following osql query to get output_text.
osql -U (login id) -P (password) -S (server name) -d (db name) -i c:(input_text).txt -o c:(output_text).txt -h-1 -s " " -n -w 2000