Quantcast
Channel: SQL Server Database Engine forum
Viewing all 12644 articles
Browse latest View live

SSH connections from TSQL?

$
0
0

Hi there,

I am currenly consuming MySQL remote servers allocated in AWS by using "link servers - odbc" approach from my Middleware SQL Server.

 

This is an example, from my stored procedure I call my link server this way:

 (NEW2 represents a Link Server name that uses an underlying mysql odbc driver) So far so good.

Set @SqlCommand=';WITH SRC AS(

                   SELECT * from OPENQUERY(NEW2,''SELECT s.invoice_no AS purchaseid

      , IFNULL(s.customer_id, ''''JP99999998'''') AS consumerid

                                                          

      , NULL AS membership_id

      , 0 AS isemployeesale

 

Now i would need to connect to other MySQL using Tcp/Ip over SSH

I can connect by using MySql workbench manually from my laptop. I am just wondering how to consume this connection from one of my stored procedures in the server....

Here you have the properties of my connection...

 

 

Any example about that would be greatly appreciated? My assumption is I need to use a SSH client at first.

 

Thanks a lot,



Return table name from DMVs?

$
0
0

Greetings.

I've been using the following query to return problematic queries for a long time now. However, I started a new gig and a coworker asked if there's a way to return the table name in the first column (OBJECT_NAME(st.objectid)).  I see how this would be an issue if multiple tables are returned in the Statement or Query columns, but even if there's only one table it constantly returns NULL. How do I return the table being queried in this column?

--Running processes
select OBJECT_NAME(st.objectid), er.session_id, er.start_time, er.status, er.command, er.database_id, sd.name,
er.wait_type, er.last_wait_type, er.wait_time,
er.wait_resource, er.cpu_time, er.reads, er.writes, er.logical_reads,
[Statement] = SUBSTRING (st.text, er.statement_start_offset/2,
 (CASE WHEN er.statement_end_offset = -1
        THEN LEN(CONVERT(NVARCHAR(MAX), st.text)) * 2
  ELSE er.statement_end_offset END -
                                er.statement_start_offset)/2),
st.text as Query, es.login_time, es.host_name, es.program_name, es.client_interface_name, es.login_name,
es.status, es.total_scheduled_time, es.total_elapsed_time, es.last_request_start_time, es.last_request_end_time--, qp.query_plan
--for backups and rollbacks, not queries
--,er.percent_complete, er.estimated_completion_time
from sys.dm_exec_requests er
join sys.dm_exec_Sessions es on er.session_id=es.session_id
left join sys.databases sd on er.database_id=sd.database_id
right join sys.dm_os_tasks ot on er.session_id=ot.session_id
CROSS APPLY sys.dm_exec_sql_text(sql_handle) AS st 
--CROSS APPLY sys.dm_exec_query_plan(er.plan_handle) qp
order by er.cpu_time desc


Thanks in advance! ChrisRDBA

How can insert the data as chunk wise in sql server temp tables...

$
0
0

Hello Everyone,


Oracle provides BULK COLLECT as one of the option to improve performance, i.e. In a stored procedure first of all I need to define a cursor, Open the cursor using BULK COLLECT option and we can perform the DML operations.
I am looking for similar functionality in SQL Server.

How can i achieve this?

Thanks ,

Ramesh Reddy,



What is the Equivalent of the Oracle statement " dbms_output.enable(1000000) " in sql server.......

$
0
0

Hi Experts,

What is the equivalent of  oracle statement "dbms_output.enable(1000000) " in sql server..

in oracle they are using this command to  set the buffer to maximum size if i am correct.

Thanks in Advance,

Ramesh Reddy Mallidi.

How to write a multi-column XOR check clause.

$
0
0

Suppose I want to design a table that contains many columns. (e.g. six or more)

Some of the columns are "bit" - NOT NULL data types. (could be two or more)

How do I write a check clause to check that if one of the bit data columns is 1 (True) then the others are 0 (False)



Ken Evans

Link Server issue

$
0
0

I am under this situation.

I have a app server APPSRVA, 2 DB server DBSRVA , DBSRVB

Link server is created at  DBSRVA to link to DBSRVB, and APPSRVA has a script bat to call a store procedure

in DBSRVA to execute query in DBSRVB.

The link server is tested ok by using management Studio install in APPSRVA, connect to DBSRVA , right click the link server and test ok.

The link server is using "be made using the login's current security context"

How ever when the script is execute , there is error Login failed for user 'NT AUTHORITY\ANONYMOUS LOGON'.

To simulate this issue, I clear the Kerberos tickets in APPSRVA. The issue happen again.

and just after when I test the link server successfully , the script can successfully run.

anyone hit this issue before ?

On windows 2016 and sql server 2016 

How can we perform the Insert and Update operations with large amount of data set ......

$
0
0

Hi Experts,

i have a result set having 1 million records .(result set is coming from  select statement). Now i want to update or insert the target tables by using this result set 10000 records  at a time.

with out using temp table  or table variable  or cursor or common table expression(cte),is there is any way to achieve this task in optimal way?

Thanks In Advance,

Ramesh Reddy Mallidi. 

How can we get the column list of the given table in SQL server with comma seperated...

$
0
0

Hi Experts,

if need one function in sql server such that if i pass the table name ,it should give the output as column list with comma separated as shown in below.

Table Creation:

Create TableA

(

Column1 int,

Column2 varchar(100),

Coulumn3 nvarchar(50)

);

i need the function with the name GetColumnList() such that 


GetColumnList(TableA)

Desired Out Put: Column1 ,Column2 ,Coulumn3 

GetColumnList(TableA,'P.')

Desired Out Put: P.Column1 ,P.Column2 ,P.Coulumn3 

Thanks In Advance,

Ramesh.



SQL Server Permissions Issue

$
0
0

Hello All,

I have 2 Schema in my SQL Server also i have 2 logins i have mapped the login with schema respectively.

for eg.

Login1 is mapped with schema1 and login2 mapped with schema2 and if i will login with login1 then i should see the list of views owned by schema1 in SSMS(expand views in SSMS) and if i will login in with login2 then i should see the views of schema2 in SSMS(expand views in SSMS).

Thanks 

ChetanV

KB3002049 deleted....

$
0
0

https://support.microsoft.com/en-us/help/3002049/cumulative-update-package-3-for-sql-server-2012-sp2

Hi.

I need this KB to restore system databases. May be somebody could help to find it? I've been tried to find it with google, but it was not successful.

Thank you.


SQL question

$
0
0
Got a question regarding syncing up SQL Jobs in all the nodes of the Alwayson cluster. We have a 3-node Alwayson cluster. With 2 nodes in on data center & another node in our DR location. Sometimes new application SQL jobs will be added to the SQL Server. Whenever those SQL jobs gets added, we want to have a sync process in place where the jobs gets copied over from primary active node to the other secondary nodes of the AAG cluster. Can't find much info on that. Any ideas? Thanks

sqldev

SQL Configuration Manager

$
0
0

can register FQDN to sql configuration manager ALIAS ?

Alias Name: DBA

Servername: dba.mydomain.com\instance

??

Default events captured in SQL error log

$
0
0
Hi All, is there any document where we can find the list of default events logged in SQL error log? One of my client is looking for this.

SQLServerLogMgr::LogWriter: Operating system error 1117(The request could not be performed because of an I/O device error.)

$
0
0

Hi All,

2 Week ago Few of the database are started randomly going to recovery pending state - I will bring it online. This started to happen with all the database and its became very annoying- when started to look what is the issue - on the error logs i can see

The system failed to flush data to the transaction log. Corruption may occur in VolumeId: H:, DeviceName: \Device\HarddiskVolume7. (The I/O device reported an I/O error.)--12:04 The system failed to flush data to the transaction log. Corruption may occur in VolumeId: G:, DeviceName: \Device\HarddiskVolume5. (The I/O device reported an I/O error.)--23:00

 Issue - Randomly the databases are going to recovery pending state on all the 3 disk and logs with issue on SQLServerLogMgr::LogWriter: Operating system error1117(The request could not be performed because of an I/O device error.) encountered. The operating system returned error1117(The request could not be performed because of an I/O device error.) to SQL Server during a read at offset 0x00000000002000 in file 'E:\Microsoft SQL Server\MSSQL12.INST01\MSSQL\Data\XXX_log.ldf'. Additional messages in the SQL Server error log and system event log may provide more detail. This is a severe system-level error condition that threatens database integrity and must be corrected immediately. Complete a full database consistency check (DBCC CHECKDB). This error can be caused by many factors; for more information, see SQL Server Books Online.

I did checkdb - No errors- the we created the 2 new disk and checked again we started to get this issue back.This morning we are getting issue


Jay

Database Access Rights

$
0
0

Hi,
I am tying to find who have given read only access to some user in the database. when the access given. Is it possible to find it? If yes any sample query please 

version : sqlserver 2016


loving dotnet


How to restore the missing Windows Installer cache files?

$
0
0

Hi Team,

When we are trying to apply the SQL Service pack ,getting below error

" The cached msi\msp file is missing "

I know this error cause when the Windows Installer database file (.msi) or the Windows Installer patch file (.msp) is missing from the Windows Installer cache.

And we tried to restore them by using the VB "FindSQLInstalls.vbs" script provided by Microsoft .

Can some one please guide\help me is there any another quick\easy process to restore missing cache files ?.Thanks

Configuring Mail on SQL Server 2012 but its keep on queueing up and failed to sent mail.

$
0
0
Error : The mail could not be sent to the recipients because of the mail server failure. (Sending Mail using Account 1 (2019-02-15T14:05:08). Exception Message: Cannot send mails to mail server. (Failure sending mail.).
)

Unable to work on SQL server management studio 17

$
0
0
TITLE: Connect to Server
------------------------------

Cannot connect to LAPTOP-AVGA5P0D.

------------------------------
ADDITIONAL INFORMATION:

A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server) (Microsoft SQL Server, Error: 2)

For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft%20SQL%20Server&EvtSrc=MSSQLServer&EvtID=2&LinkId=20476

------------------------------

The system cannot find the file specified

------------------------------
BUTTONS:

OK
-----------------------------

why we dont possibility rollback database state without full backup see me question

$
0
0
1) I have a ms sql database for example b.mdf (say MS SQL 2012) and transact log b.ldf which has never been cleaned.

2) All files database are full perfect works.

3) Full backup is newer doing in database b.

4) Transact log has never cleaned and he have all information on the all time witch is using database.

Why is there no mechanism to rollback back to a certain date and time ?

I know mechanism an stratege restore database. I havnt full backup database.

Its very actualy problem.Many peopls offen try resolve this problem, but how is step to resolved it.

Thanks for the answer.

Attach database with only MDF file

$
0
0

Dear All,

SQL server version is 2008 R2 Standard Edition . Only a particular mdf exists for a database , there is no ldf file for the database . Can we attach the database without ldf.

Appreciate your kind cooperation .

Best Regards,
Sandy

Viewing all 12644 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>