Quantcast
Channel: Latest Questions on SQL Server Q&A from the SQL Server Central community
Viewing all 11276 articles
Browse latest View live

Where can I obtain Microsoft.ACE.OLEDB.16.0 Provider?

$
0
0

I'm trying to use the Import Data wizard in SSMS 17.7 to import a table from an Excel file, but it's saying that I don't have Microsoft.ACE.OLEDB.16.0 Provider registered on my machine. How/where can I get it? I've found a lot of links for it online, but all so far have been to something different. Thanks.


USE CTE slow in view than use temp table in sp

$
0
0

I have question for SQL professional for help. I have a piece query run slow in a view(25s), I use temp table can improve the performance to 2s. Since temp table cannot use in view, I try to use CTE. But for some reason it slow again. Here is the query in view:

	SELECT mc.CustID,
		mc.ScustID,
		STUFF(REPLACE((SELECT '#!' + LTRIM(RTRIM(code)) AS 'data()'
				FROM (SELECT code
					FROM [sqlmc].mc1015.dbo.texture am WITH (NOLOCK)
					INNER JOIN [sqlmc].mc1015.dbo.texture_flags af WITH (NOLOCK)
						ON af.mt_id = am.mt_id AND am.ma_id = 3
					WHERE af.me_id = ep.me_id) temp 
	FOR XML PATH('')),' #!',','), 1, 2, '')	AS SCodes
	FROM c_mid_vw mc WITH (NOLOCK)
	INNER JOIN [sqlmc].mc1015.dbo.user pm WITH (NOLOCK)
		ON pm.Cust_id = mc.mCust_id
	INNER JOIN [sqlmc].mc1015.dbo.event_users ep WITH (NOLOCK)
		ON pm.pt_id = ep.pt_id
		AND ep.ptt_id IN (1, 8, 9)

sqlmc is a link server; c_mid_vw is on local server. I modified it to use temp table but not in view:

SELECT me_id,Cust_id
	INTO #mc1015  
	FROM [sqlmc].mc1015.dbo.user pm WITH (NOLOCK)
	INNER JOIN [sqlmc].mc1015.dbo.event_users ep WITH (NOLOCK)
		ON pm.pt_id = ep.pt_id
		AND ep.ptt_id IN (1, 8, 9)


SELECT DISTINCT code,af.me_id
INTO #md1015
					FROM [sqlmc].mc1015.dbo.texture am WITH (NOLOCK)
					INNER JOIN [sqlmc].mc1015.dbo.texture_flags af WITH (NOLOCK)
						ON af.mt_id = am.mt_id AND am.ma_id = 3
					JOIN #mc1015 a ON a.me_id=af.me_id


	SELECT mc.CustID,
		mc.ScustID,
		STUFF(REPLACE((SELECT '#!' + LTRIM(RTRIM(code)) AS 'data()'
				FROM (SELECT code FROM #md1015 b WHERE b.me_id=a.me_id ) temp 
	FOR XML PATH('')),' #!',','), 1, 2, '')	AS SCodes
	FROM c_mid_vw mc WITH (NOLOCK)
	INNER JOIN #mc1015 a ON a.Cust_id = mc.mCust_id

it give good performance. when I use cte for same concept since we can use CTE in view, it slow again(25s):

;WITH  mc1015(Cust_id,me_id)
AS(
 	SELECT TOP 100 PERCENT Cust_id,me_id
	FROM [sqlmc].mc1015.dbo.user pm WITH (NOLOCK)
	INNER JOIN [sqlmc].mc1015.dbo.event_users ep WITH (NOLOCK)
		ON pm.pt_id = ep.pt_id
		AND ep.ptt_id IN (1, 8, 9)
	ORDER BY me_id
),
md1015(code,me_id)
AS
(
SELECT 
		DISTINCT code,af.me_id
					FROM [sqlmc].mc1015.dbo.texture am WITH (NOLOCK)
					INNER JOIN [sqlmc].mc1015.dbo.texture_flags af WITH (NOLOCK)
						ON af.mt_id = am.mt_id AND am.ma_id = 3
					JOIN mc1015 a ON a.me_id=af.me_id
)
	SELECT mc.CustID,
		mc.ScustID,
		STUFF(REPLACE((SELECT '#!' + LTRIM(RTRIM(code)) AS 'data()'
				FROM (SELECT code FROM md1015 b WHERE b.me_id=a.me_id ) temp 
	FOR XML PATH('')),' #!',','), 1, 2, '')	AS SCodes
	FROM c_mid_vw mc WITH (NOLOCK)
	INNER JOIN mc1015 a ON a.Cust_id = mc.mCust_id

Finding the MIN of a group of values not used in a previous group

$
0
0

I have been having trouble finding anything on google because I'm not sure how to phrase the search. What I need to do is to select the MIN R from each Id group that hasn't already been selected by a previous group. This is the trimmed down version with an example of a row that has no R value.

I have a table simplified

CREATE TABLE Data(Id int, R int) INSERT INTO Data VALUES(1,1),(2,1),(3,2),(3,3),(4,2),(4,3),(4,4),(5,4),(5,5),(6,5),(6,6),(7,6)

Starting Data

IdR1121323242434454556576

Desired Output

IdR112NULL3243546576

Any help is appreciated.

Categorizing ACH Transactions

$
0
0

Hello,

I am trying to think of a way to derive types of transactions from a daily transaction table. For example, when ACH transactions are posted, there's always a transaction narrative. Within each narrative we have a string often separated by "/". An illustration looks like this:

STATE FARM BANK/PAYMENT/181004/WEB. Another one looks like this:

PITT TUITION/PITTPAYMNT/181005/WEB. The goal is to classify payments into categories such as mortgage, credit card, utilities, etc.. I think a fair amount of manual effort is required, but if I could aggregate similar lines, that would be a huge start. The goal is to capture a category for most of the transactions. The goal is to build a customer profile.

update table many times in one procedure

$
0
0

hi,

one of stored procedure which i have to maintenance has 51 updates the same table with different condition, every update has parameter for cntrt_id (i have index here and rest of table is on include clause because table has 10 column), when this sp is run using SSMS with parameter for cntrt_id it works good, (i know that i can't run t-sql parallel) but when im running this SP using ADF on multiple thread i have deadlocks, and i really don't know what i should change to prevent deadlocks. I though that index cant prevent but in my opinion 51 updates kill this process, and i think that someone should start of thinking what kind of data and made some manipulation in those data before loading to DB instead of making updates.

maybe a could change isolation level to read commited isolation snapshot?

How to check specific row was deleted in transaction history

$
0
0

Hi,

Windows 2008R2/MS SQL 2012. I did a delete like:

delete from table where id = 103

was able to use fn_dblog to find delete activity and who did the deleted. Where I can find that row of 103 was deleted. Many thanks.

Chris

http://nutritionextract.com/mct-oil-powder/

$
0
0

mct oil The coconut tree has regularly been identified as a kalpavriksha since of its many uses. Actually, most families on the Southern coast of India unfailingly add coconut to their food. They can not imagine food with out coconut.

However there is additionally an irrational worry of cooking with coconut oil. The blame has been laid on the high concentration of saturated fat within the oil. Thankfully, the hindrance is changing. Today, we're seeing a resurgence of curiosity in coconut oil because of more than a few scientific reviews on it all over the world.

http://nutritionextract.com/mct-oil-powder/

SS Report Builder 2016 Parameter Difficulty

$
0
0

I am building a report in SS Report Builder 2016 and need to grant users the ability to sort the report by Vendor Names, which is a column from my second dataset. Both datasets are using embedded queries, from different servers, that I do not have the ability to link.


Get the list of all authors who have submitted their papers

$
0
0

AUTHOR :{a_id,a_first_name,a_last_name,a_phone_no,a_email,a_pwd};_______________PAPER :{ paper_id, title,abstract, file_name,author_id}

Using a variable for database name in select from table in a stored proc

$
0
0
— Example stored Proc
— I would like to select from the table ExportSettings from both within the  — current database & from another database on the same server
— Real DATABASENAME is ST_v4051 but want to reference it as a variable 
— How do I resolve DATABASENAME?
—.Thank you & kind regards David

CREATE PROCEDURE [dbo].[MyBacgroundTask]
As
Begin
Declare @col1 nvarchar(50), 
@col2 nvarchar(50)


SELECT TOP (1)
@col1 = col1,
@col2 = col2
—FROM ST_v4051.dbo.ExportSettings
FROM DATABASENAME.dbo.ExportSettings
END





How do you set the running total to 0 when it gets below 0 (-1) ?

$
0
0

example:

bal

2 2

-3 0

1 1

3 4

-1 3

2 5

-6 0

3 3

http://www.trybionutrition.com/revyve-skin/

$
0
0

Hormones One more cause of liver body organ locations surprisingly is not described previously because it only only happens in as well as then only during pregnancy or while getting oral contraceptives. It is most known Revyve skin 'the pregnancy mask'. These locations are believed to provide the androgenic hormone or testosterone released during pregnancy becoming a rise in the production of melanin when the expectant mother is in the sun for more than very short times.

http://www.trybionutrition.com/revyve-skin/

Checking variables for WAITFOR TIME and DELAY

$
0
0
-- David 06/11/2018
-- I have two (2) variables for the WAITFOR function
-- @timeToRun is the DELAY variable which is used in the WAITFOR DELAY
-- @time is the TIME variable which is used in the WAITFOR TIME
-- Is there a better way to validate that they are set correctly and also is -- there a better way to don the IF statement?
-- These variables are returned as a varchar in a SELECT statement.
-- Should they be assigned to a different type for checking?
-- Kind regards, David


DECLARE @timeToRun nvarchar(50)
SET @timeToRun = '00:00:05.500' -- Wait 5 & a half a secondss
DECLARE @time nvarchar(50)
SET @time = '14:56' -- SET @time to 11 pm
--SET @time = '' -- SET @time to blank
SET @time = '00:00' -- SET @time to blank

--WHILE 1 = 1
--BEGIN
  IF @time <> '00:00'
    AND @time <> ''
  BEGIN
    WAITFOR time @time
	SELECT 'Exact Time is up'
  END
  ELSE
  IF
    @timeToRun <> '00:00:00'
    AND @timeToRun <> ''
  BEGIN
    WAITFOR DELAY @timeToRun
	SELECT 'Delay Time is up'
  END
--END

write query for get value from same table

$
0
0

suppose this is table name user with content follwing

id name m_id

1 A Null

2 B 1

3 C 1

4 D 2

write select query for output should be

id name m_id

1 A Null

2 B A

3 C A

4 D B

https://pbrworldfinalslive.de/


Get the list of all the (reviews and papers) which has been reviewed by reviewer and also get the author name for that list of the paper.

$
0
0

Schema :

AUTHOR:{a_id,a_first_name,a_last_name,a_phone_no,a_email,a_pwd}

PAPER: {paper_id,title,abstract,file_name,author_id}

REVIEWER:{rvr_id,rvr_first_name,rvr_last_name,rvr_phone,rvr_email,rvr_pwd,rvr_interest}

REVIEW:{rv_id,clarity,relevance,technical_rate,rvr_id,paper_id}

**THIS IS A BIT INTIMIDATING FOR ME**

THANK YOU VERY MUCH. GOD BLESS YOU.


Unable to identify missing record using view

$
0
0

SQL that works as it should other than I can't limit to active students

SELECT stud.other_id
FROM   student stud
       LEFT JOIN (SELECT *
                  FROM   Openquery (adsi, 'SELECT sAMAccountName
  FROM ''LDAP://.....''
WHERE objectClass = ''User''
'))AD
              ON stud.other_id = AD.samaccountname
                 AND ad.samaccountname IS NULL 

View used to get active students

CREATE VIEW [dbo].[VW_Enrolled_Students] AS SELECT dbo.student.student_id, dbo.student.name_id, dbo.student_ew.entity_id, dbo.student_ew.ew_date, dbo.student.other_id, dbo.student.student_in_stn, dbo.student.grad_yr FROM dbo.student INNER JOIN dbo.student_ew ON dbo.student.student_id = dbo.student_ew.student_id WHERE (dbo.student_ew.withdrawal_date IS NULL) GO

code used to identify missing AD accounts for active students

SELECT Stud.other_id FROM [vw_enrolled_students] Stud left JOIN (SELECT * FROM Openquery (adsi, 'SELECT sAMAccountName FROM ''LDAP://......'' WHERE objectClass = ''User'' ')) AD ON Stud.other_id = ad.samaccountname AND ad.samaccountname IS NULL

The OLE DB provider "MSDASQL" for linked server "" reported an error.

$
0
0

Hi Team,

I need the suggestion on the below error where sql agent job fails with the below error and upon rerun it got suceeed , but i need to investigate on what caused this issue , any suggestions are appreciated

The OLE DB provider "MSDASQL" for linked server "" reported an error. The provider reported an unexpected catastrophic failure. [SQLSTATE 42000] (Error 7399) Cannot obtain the schema rowset "DBSCHEMA_COLUMNS" for OLE DB provider "L" for linked server "". The provider supports the interface, but returns a failure code when it is used. [SQLSTATE 42000] (Error 7311). The step failed.

Date output format in SSMS 2014 AND 2017 as Oct 26 2018

$
0
0

Hello,

I have two identical queries, that I've executed against a SQL Server 2014 server, and another against SQL Server 2017. One of the date columns is returning in the query result window in the format of Oct 26 2018 on the 2014 server. On the 2017 server, it is returning in the more familiar format of 2018-10-26. Since it is occurring on only one of the database that I can tell, I assume this is database setting, but I'm unable to find out where this difference is being driven from.

Thank you.

How to call parent package variable value into child package ?

Viewing all 11276 articles
Browse latest View live