I am trying to copy the trace file information to SQL table with fn_trace_gettable function, but while running this function I am getting 'Trace file name is invalid'. And I confirmed the path and file name are correct and the default trace is enabled. Following is my SQL code, what I am doing wrong?
USE TestDB
SELECT * INTO [dbo].[traceTable]
FROM ::fn_trace_gettable(N'D:\MAT25.trc', default)
Error Message:
Msg 19050, Level 16, State 6, Line 11
Trace file name 'D:\MAT25.trc' is invalid.
The statement has been terminated.
Related
I have these pymmsql index errors I created 3 indexes in my code and I want to drop them but they wouldn't drop I get these errors
Code:
DbConnect = 'Micros'
myDbConn = pymssql.connect(*******,"******", "*******",DbConnect)
cursor = myDbConn.cursor()
cursor.execute("""DROP INDEX [IF EXISTS]
Micros ON payrolldata;""")
cursor.execute("""DROP INDEX [IF EXISTS]
MainSort ON s20data,StoreSort ON s20data;""")
myDbConn.commit()
Error:
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Python37-32\lib\tkinter\__init__.py", line 1705, in __call__
return self.func(*args)
File "C:\Python37-32\SqlVersionpr_import.py", line 840, in proceed
Micros ON payrolldata;""")
File "src\pymssql.pyx", line 465, in pymssql.Cursor.execute
pymssql.ProgrammingError: (102, b"Incorrect syntax near 'Micros'.DB-Lib error message 20018, severity
15:\nGeneral SQL Server error: Check messages from the SQL Server\n")
Correct syntax would be.
DROP INDEX IF EXISTS IndexName;
DROP INDEX IndexName;
Square brackets mean that parameter or part of statement is optional.
See documentation
https://learn.microsoft.com/en-us/sql/t-sql/statements/drop-index-transact-sql?view=sql-server-ver15
I started to explore R on SQL 2016 but running into errors. I resolved a few starting errors but can't get through with this one:
exec sp_execute_external_script
#language =N'R',
#script=N'OutputDataSet<-InputDataSet',
#input_data_1 =N'select 1 as hello'
with result sets (([hello] int not null));
go
Error:
Msg 39021, Level 16, State 1, Line 1
Unable to launch runtime for 'R' script. Please check the configuration of the 'R' runtime.
Msg 39019, Level 16, State 1, Line 1
An external script error occurred:
Unable to launch the runtime. ErrorCode 0x80070490: 1168(Element not found.).
Msg 11536, Level 16, State 1, Line 1
EXECUTE statement failed because its WITH RESULT SETS clause specified 1 result set(s), but the statement only sent 0 result set(s) at run time.
I found answers to set the Working Directory for R in Rlauncher.config.
But there is no Rlauncher.config on below path on my machine. Not Sure why?
C:\Program Files\Microsoft SQL Server 2016\MSSQL13.SQL2016\MSSQL\Binn
When I check the error log I see the following errors:
2016-11-13 19:41:14.131 Security Context Manager is initialized successfully.
2016-11-13 19:41:14.132 Satellite Session Manager is initialized successfully.
2016-11-13 19:41:14.133 Launcher DLL RLauncher.dll not loaded! Error: 126
2016-11-13 19:41:14.133 Failed to load the launcher RLauncher.dll and check satellite version
2016-11-13 19:41:14.133 No Launcher dlls were registered!
Please help.
Please make sure you have installed the R Services (In-Database) in the SQL Setup Feature selection page. Please note this is different from the R Server option. See here for details.
I'm trying to create a database where the data and log files are saved to the E drive but not sure how to do so. I've tried:
CREATE DATABASE TachographDataContent_Archive
[ON E:\MySqlDir\MSSQL.MSSQLSERVER\MSSQL\Data]
[LOG ON {D:\MySqlDir\MSSQL.MSSQLSERVER\MSSQL\Data}]
And I'm getting this error:
Msg 156, Level 15, State 1, Line 1
Incorrect syntax near the keyword 'IF'.
Msg 102, Level 15, State 1, Line 1
Incorrect syntax near 'TachographDataContent_Archive'.
To create database using query, you need to mention .mdf and .ldf file. So try below script.
Like this
CREATE DATABASE [TachographDataContent_Archive]
ON PRIMARY (NAME = 'TachographDataContent', FILENAME = 'E:\MySqlDir\MSSQL.MSSQLSERVER\MSSQL\Data\TachographDataContent.mdf')
LOG ON
(NAME = 'TachographDataContent_log', FILENAME = 'E:\MySqlDir\MSSQL.MSSQLSERVER\MSSQL\Data\TachographDataContent_log.ldf')
GO
good luck...
I want to create a database from my local computer through a stored procedure it is not allowing to create the database .
I'm getting this error:
Msg 5133, Level 16, State 1, Line 1
Directory lookup for the file "D:\SHA_dat\SHA.dat" failed with the operating system error 2(The system cannot find the file specified.).
Msg 1802, Level 16, State 1, Line 1
CREATE DATABASE failed. Some file names listed could not be created. Check related errors.
And my code is here:
SELECT #cSQL = 'CREATE DATABASE '+#cDBName+' ON ( NAME = '''+#cDBName+'_data'''+',
FILENAME = ' + quotename(#cDbPath)+ ') LOG ON ( NAME = '''+#cDBName+'_Log'',
FILENAME = ' + quotename(#cLogPath)+ ')'
select #cSQL
where #cDBName refers for the Datbase name to create and #cDBPath and #cLogPath refers to netork paths to create the .dat and .log files
Can anyone help me?
You write that #cDBPath and #cLogPath are network paths. This won't work. While the network path is available for you and you are submitting the CREATE DATABASE, the SQL Server service is processing the CREATE DATABASE. The service is running in it's own logon session with it's own user account and it does not have the same drives mapped as you have. So you cannot use a network drive as you do it.
BTW, the same applies when you want to recover from a backup. The backup needs to be available on a local drive so that the SQL Server service can access it.
I wont restore my database but the location path is not the same. How can i change this path(partition)?
RESTORE DATABASE [MY_DATABASE]
FROM DISK = 'C:\Content.bak'
WITH FILE = 1,
NOUNLOAD,
STATS = 10
Error Message:
Msg 5133, Level 16, State 1, Line 1
Directory lookup for the file "F:....\Content01.mdf" failed with the operating system error 3(failed to retrieve text for this error.
Reason: 15100).
Msg 3156, Level 16, State 3, Line 1
File 'Content01' cannot be restored to 'F:....\Content01.mdf'. Use WITH MOVE to identify a valid location for the file.
Msg 5133, Level 16, State 1, Line 1
Directory lookup for the file "H:....\Content01_log.LDF" failed with the operating system error 3(failed to retrieve text for this
error. Reason: 15105).
Msg 3156, Level 16, State 3, Line 1
File 'Content01_log' cannot be restored to 'H:....\Content01_log.LDF'. Use WITH MOVE to identify a valid
location for the file.
Msg 3119, Level 16, State 1, Line 1
Problems were identified while planning for the RESTORE statement. Previous messages provide details.
Msg 3013, Level 16, State 1, Line 1
RESTORE DATABASE is terminating abnormally.
THANKS.
RESTORE DATABASE [My_Database]
FROM DISK = 'C:\Content.bak'
WITH MOVE 'MyDatabase_Data' TO 'C:\Data\MyDatabase_Data.mdf',
MOVE 'MyDatabase_Log' TO 'C:\Data\MyDatabase_Log.ldf',
REPLACE,
STATS=10
Use the WITH MOVE command of the restore as discussed in this SO Question.
If anyone is here because they are restoring a database with multiple files, each destination file needs a new name. Using SQL Server 2008 R2, the gui does not provide an obvious clue nor does it solve it automatically.