2022-07-06 14:58:46.730 62c5279c.5068 postgres 281457772402032 WDRSnapshot 209240673 dn_6001_6002 00000 5066549580791808 [BACKEND] CONTEXT: SQL statement "insert into snapshot.snap_global_statio_all_indexes(snapshot_id, db_name, "snap_node_name" , "snap_relid" , "snap_indexrelid" , "snap_schemaname" , "snap_relname" , "snap_indexrelname" , "snap_idx_blks_read" , "snap_idx_blks_hit" ) select snapshot_id, dbname1, "snap_node_name" , "snap_relid" , "snap_indexrelid" , "snap_schemaname" , "snap_relname" , "snap_indexrelname" , "snap_idx_blks_read" , "snap_idx_blks_hit" from wdr_xdb_query('dbname=dcep_acq_db'::text, 'select 18136, ''dcep_acq_db'', t.* from dbe_perf.global_statio_all_indexes t'::text) as i(snapshot_id int8, dbname1 text, "snap_node_name" name, "snap_relid" oid, "snap_indexrelid" oid, "snap_schemaname" name, "snap_relname" name, "snap_indexrelname" name, "snap_idx_blks_read" numeric, "snap_idx_blks_hit" numeric)"
2022-07-06 14:58:46.803 62c532a6.4918 dcep_acq_db 281452314695024 dn_6001 0 dn_6001_6002 28000 0 [BACKEND] FATAL: Forbid remote connection with initial user.
2022-07-06 14:58:46.808 62c532a6.4918 dcep_acq_db 281452314695024 dn_6001 0 dn_6001_6002 28000 0 [BACKEND] FATAL: Forbid remote connection with initial user.
2022-07-06 15:04:46.739 62c5279c.5068 postgres 281457772402032 WDRSnapshot 209240703 dn_6001_6002 08001 5066549580791808 [BACKEND] CONTEXT: SQL statement "insert into snapshot.snap_global_statio_all_indexes(snapshot_id, db_name, "snap_node_name" , "snap_relid" , "snap_indexrelid" , "snap_schemaname" , "snap_relname" , "snap_indexrelname" , "snap_idx_blks_read" , "snap_idx_blks_hit" ) select snapshot_id, dbname1, "snap_node_name" , "snap_relid" , "snap_indexrelid" , "snap_schemaname" , "snap_relname" , "snap_indexrelname" , "snap_idx_blks_read" , "snap_idx_blks_hit" from wdr_xdb_query('dbname=dcep_acq_db'::text, 'select 18142, ''dcep_acq_db'', t.* from dbe_perf.global_statio_all_indexes t'::text) as i(snapshot_id int8, dbname1 text, "snap_node_name" name, "snap_relid" oid, "snap_indexrelid" oid, "snap_schemaname" name, "snap_relname" name, "snap_indexrelname" name, "snap_idx_blks_read" numeric, "snap_idx_blks_hit" numeric)"
2022-07-06 15:04:46.739 62c5279c.5068 postgres 281457772402032 WDRSnapshot 209240703 dn_6001_6002 01000 5066549580791808 [BACKEND] WARNING: WDR snapshot failed
you can try Change the authentication method from sha256 back to trust.
It is estimated that it is a problem with authorization authentication.
Related
INSERT INTO PHONE_NUMBERS(
[OWNER_ID]
, OWNER_TYPE_ID
, PHONE_NUMBER_TYPE_ID
, AREA_CODE
, PREFIX
, PHONE_NUMBER_BODY
, IS_ACTIVE)
SELECT
INS_COMPANY_ID
, #OWNER_TYPE_ID OWNER_TYPE_ID
, #PHONE_NUMBER_TYPE_ID PHONE_NUMBER_TYPE_ID
, LEFT(try_convert(varchar(50), cast(([Insurance Phone]) as decimal(38,0) ) ),3)
, substring( try_convert(varchar(50), cast(([Insurance Phone]) as decimal(38,0) ) ),4,3)PREFIX
, RIGHT(try_convert(varchar(50), cast(([Insurance Phone]) as decimal(38,0) ) ),4)
, 1 IS_ACTIVE
FROM
Insurance_Companies_28012020 EE
JOIN
INS_COMPANIES IC ON ee.[Insurance Name] = IC.COMPANY_NAME
WHERE
ic.is_active = 1 AND [Insurance Phone] IS NOT NULL
Here my Phone is like 895-541-8541. This phone data is imported from Excel and table data type is varchar.
Your cast(([Insurance Phone]) as decimal won't work if there are dashes in the string.
There is no reason to cast to a decimal before converting to varchar. If Insurance Phone is truly a varchar column, then there is a lot of unnecessary casting and converting in your query:
INSERT INTO
PHONE_NUMBERS( [OWNER_ID]
, OWNER_TYPE_ID
, PHONE_NUMBER_TYPE_ID
, AREA_CODE
, PREFIX
, PHONE_NUMBER_BODY
, IS_ACTIVE
)
SELECT INS_COMPANY_ID
, #OWNER_TYPE_ID OWNER_TYPE_ID
, #PHONE_NUMBER_TYPE_ID PHONE_NUMBER_TYPE_ID
, LEFT([Insurance Phone], 3)
, substring( [Insurance Phone],4,3) PREFIX
, RIGHT([Insurance Phone],4)
, 1 IS_ACTIVE
FROM Insurance_Companies_28012020 EE
join INS_COMPANIES IC on ee.[Insurance Name] =IC.COMPANY_NAME where ic.is_active=1 and [Insurance Phone] is not null
I have a employee table , from where I am finding out the supervisor(team lead) and the manager details based on the User ID . I have a SSIS package which appends newly created Users into my table.
Below is what i am doing currently .
appending newly created user ID into my Sql table from the master table.
finding the supervisor and the manager , based on the employee USER ID.
Now , when an existing employee changes his manager or the supervisor, how can I update the new changes from the master table to my sql table. I dont want to truncate and load the table either since this table is used in an application.
here is the query:
-- load new employee details
INSERT INTO [dbo].[Active_Directory_COE]
(
[USER_ID]
, [USER_TYPE_NM]
, [USER_CLASS]
, [LAST_NM]
, [FIRST_NM]
, [MIDDLE_INIT]
, [EMAIL_ADDRESS]
, [EMP_JOB_DESC]
, [BUSINESS_UNIT_CD]
, [BUSINESS_UNIT_NM]
, [BUSINESS_SEGMENT]
, [SUPERVISOR_ID]
, [EMP_FULL_NM]
, [MANAGER_NAME]
, [SUPERVISOR_NAME]
, [SUPERVISOR_EMAIL_ADDRESS]
, [MANAGER_EMAIL_ADDRESS]
, [TEAM]
, [REGION]
, [SUB_REGION]
, [SALES_OFFICE]
, [SALES_GROUP]
, [EMPLOYEE_STATUS]
, [SURVEY_GROUP]
, [SURVEY_APPLICABLE]
, [REGION_CSSC]
, [SALES_ORG]
, [SALES_OFFICE_MULTIPLE]
, [TE_JOINING_DT]
)
SELECT
[A1].[USER_ID]
, [A1].[USER_TYPE_NM]
, [A1].[USER_CLASS]
, [A1].[LAST_NM]
, [A1].[FIRST_NM]
, [A1].[MIDDLE_INIT]
, [A1].[EMAIL_ADDRESS]
, [A1].[EMP_JOB_DESC]
, [A1].[BUSINESS_UNIT_CD]
, [A1].[BUSINESS_UNIT_NM]
, [A1].[BUSINESS_SEGMENT]
, [A1].[SUPERVISOR_ID]
, [A1].[EMP_FULL_NM]
, [D].[EMP_FULL_NM] AS [Manager_Name]
, [C].[EMP_FULL_NM] AS [Supervisor_name]
, [C].[EMAIL_ADDRESS] AS [Supr_Email_AD]
, [D].[EMAIL_ADDRESS] AS [Mangaer_Email_Ad]
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, [A1].[SERVICE_CREDIT_DT]
FROM
(
SELECT
[A].[USER_ID]
, [A].[USER_TYPE_NM]
, [A].[USER_CLASS]
, [A].[LAST_NM]
, [A].[FIRST_NM]
, [A].[MIDDLE_INIT]
, [A].[EMAIL_ADDRESS]
, [A].[EMP_JOB_DESC]
, [A].[BUSINESS_UNIT_CD]
, [A].[BUSINESS_UNIT_NM]
, [A].[BUSINESS_SEGMENT]
, [A].[SUPERVISOR_ID]
, [A].[EMP_FULL_NM]
, [A].[SERVICE_CREDIT_DT]
FROM [dbo].[Active_Directory] [A]
LEFT OUTER JOIN [dbo].[Active_Directory_COE] [B]
ON [A].[USER_ID] = [B].[USER_ID]
WHERE [B].[USER_ID] IS NULL
) [A1]
INNER JOIN [dbo].[Active_Directory] [C]
ON [C].[USER_ID] = [A1].[SUPERVISOR_ID]
INNER JOIN [dbo].[Active_Directory] [D]
ON [C].[SUPERVISOR_ID] = [D].[USER_ID];
I'm using MS Visual Studio 2012. I'm having an issue with writing a subquery. This is the entire query as follows:
SELECT ACCOUNTNUM
, NAME
, ADDRESS
, PHONE
, TELEFAX
, INVOICEACCOUNT
, CUSTGROUP
, PAYMTERMID
, CURRENCY
, DIMENSION
, CELLULARPHONE
, STATISTICSGROUP
, PAYMMODE
, NAMEALIAS
, CONTACTPERSONID
, STREET
, PARTYID
, SEGMENTID
, TAXGROUP
, DATAAREAID
, ISNULL((
SELECT PERCENT1 AS DiscCount
FROM PRICEDISCTABLE
WHERE (DATAAREAID = CUSTTABLE.DATAAREAID)
AND (ACCOUNTRELATION = CUSTTABLE.ACCOUNTNUM)
), 0) / 100 AS DiscCount
, (
SELECT NAME
FROM CONTACTPERSON
WHERE (DATAAREAID = CUSTTABLE.DATAAREAID)
AND (CUSTACCOUNT = CUSTTABLE.ACCOUNTNUM)
AND (CONTACTPERSONID = CUSTTABLE.CONTACTPERSONID)
) AS ContactName
, (
SELECT PHONE
FROM CONTACTPERSON AS CONTACTPERSON_1
WHERE (DATAAREAID = CUSTTABLE.DATAAREAID)
AND (CUSTACCOUNT = CUSTTABLE.ACCOUNTNUM)
AND (CONTACTPERSONID = CUSTTABLE.CONTACTPERSONID)
) AS ContactPhone
, ISNULL((
SELECT STATGROUPNAME
FROM CUSTSTATISTICSGROUP
WHERE (DATAAREAID = CUSTTABLE.DATAAREAID)
AND (CUSTSTATISTICSGROUP = CUSTTABLE.STATISTICSGROUP)
), 0) AS StatisticsName
FROM CUSTTABLE
WHERE CUSTGROUP = #ty
AND DATAAREAID = N'OTN'
AND STATISTICSGROUP LIKE #ss;
and then I get the error
Subquery returned more than 1 value. This is not permitted when the
subquery follows =, !=, <, <= , >, >= or when the subquery is used as
an expression.
Where the issue comes from?
Issue is that one of your subqueries returns more than one value (HEY, ERROR DESCRIPTION SAYS THAT).
How to find which one?
Try commenting out each subquery in your select statement until your query works fine.
How to fix it?
That's probably the best case to use CROSS APPLY. That'd be your query:
SELECT ACCOUNTNUM
, NAME
, ADDRESS
, PHONE
, TELEFAX
, INVOICEACCOUNT
, CUSTGROUP
, PAYMTERMID
, CURRENCY
, DIMENSION
, CELLULARPHONE
, STATISTICSGROUP
, PAYMMODE
, NAMEALIAS
, CONTACTPERSONID
, STREET
, PARTYID
, SEGMENTID
, TAXGROUP
, DATAAREAID
, ISNULL(T1.DiscCount, 0) / 100 AS DiscCount
, T2.ContactName
, T3.ContactPhone
, ISNULL(T4, 0) AS StatisticsName
FROM CUSTTABLE
CROSS APPLY (
SELECT PERCENT1 AS DiscCount
FROM PRICEDISCTABLE
WHERE DATAAREAID = CUSTTABLE.DATAAREAID
AND ACCOUNTRELATION = CUSTTABLE.ACCOUNTNUM
) AS T1
CROSS APPLY (
SELECT NAME
FROM CONTACTPERSON
WHERE DATAAREAID = CUSTTABLE.DATAAREAID
AND CUSTACCOUNT = CUSTTABLE.ACCOUNTNUM
AND CONTACTPERSONID = CUSTTABLE.CONTACTPERSONID
) AS T2
CROSS APPLY (
SELECT PHONE
FROM CONTACTPERSON AS CONTACTPERSON_1
WHERE DATAAREAID = CUSTTABLE.DATAAREAID
AND CUSTACCOUNT = CUSTTABLE.ACCOUNTNUM
AND CONTACTPERSONID = CUSTTABLE.CONTACTPERSONID
) AS T3
CROSS APPLY (
SELECT STATGROUPNAME
FROM CUSTSTATISTICSGROUP
WHERE DATAAREAID = CUSTTABLE.DATAAREAID
AND CUSTSTATISTICSGROUP = CUSTTABLE.STATISTICSGROUP
) AS T4
WHERE CUSTGROUP = #ty
AND DATAAREAID = N'OTN'
AND STATISTICSGROUP LIKE #ss;
Also, these can be rewritten as simple INNER JOINS.
When encountering this error, try running the subqueries individually and if more than one record is returned then refine your conditions to ensure only one record is returned.
Of course, if more than one record is wanted then you need to change your query to use a join instead of a subquery.
I have a table named FriendRequests which has columns for e.g. Id, RequestFrom and RequestTo
which has data for e.g
Id RequestFrom RequestTo
1 3C24B040-3CE2-46B6-950F-D76A8275505D 4C668138-BB4F-4228-9946-44DED1851C51
2 4C668138-BB4F-4228-9946-44DED1851C51 3C24B040-3CE2-46B6-950F-D76A8275505D
So now i want to find out how many such combinations are missing. For e.g. that table has only one row and the second row is missing.
I have tried this but not working
SELECT RequestTo ,
RequestFrom ,
IsPending ,
IsAccept ,
ActedDate
FROM FriendRequests
WHERE RequestFrom NOT IN ( SELECT DISTINCT
requestTo
FROM FriendRequests )
Try this:
SELECT f1.RequestTo ,
f1.RequestFrom ,
f1.IsPending ,
f1.IsAccept ,
f1.ActedDate
FROM FriendRequests f1
EXCEPT
SELECT f1.RequestTo ,
f1.RequestFrom ,
f1.IsPending ,
f1.IsAccept ,
f1.ActedDate
FROM FriendRequests f1
JOIN FriendRequests f2
ON f1.RequestFrom = f2.RequestTo
AND f2.RequestFrom = f1.RequestTo
Edit: Here is another approach
SELECT f1.RequestTo ,
f1.RequestFrom ,
f1.IsPending ,
f1.IsAccept ,
f1.ActedDate
FROM FriendRequests f1
WHERE NOT EXISTS (SELECT *
FROM FriendRequests f2
ON f1.RequestFrom = f2.RequestTo
AND f2.RequestFrom = f1.RequestTo)
It will find all the friend requests that has not been accepted.
work on sql-server-2005
SELECT A.specific_customization_id ,
A.customization_id ,
A.customization_value ,
A.customization_price ,
A.customization_cost ,
A.customization_code ,
A.customization_check ,
A.sort_order ,
A.option_code ,
A.product_id ,
A.image_1 ,
A.image_2 ,
A.MainProductID ,
A.customization_product_id ,
A.inactive ,
A.customization_description ,
A.customization_select ,
A.UOM ,
A.allow_recur ,
auto_reorder = CASE A.MainProductID --it's an int type column
WHEN NULL THEN A.allow_recur
ELSE ( SELECT allow_recur
FROM wc_product
WHERE product_id = A.MainProductID
)
END
FROM dbo.wc_product_specific A
WHERE A.product_id = 1133
Using the above query I want to set auto_reorder column value .want to set two login
When My MainProductID column is null I want to set allow_recur column value
When it’s not null I want to set another table column value
My logic 2) works fine ,fail to understand why does 1) not work? Help me to fix the problem?
If have any query plz ask thanks in advance.
Does this work:?
SELECT A.specific_customization_id ,
A.customization_id ,
A.customization_value ,
A.customization_price ,
A.customization_cost ,
A.customization_code ,
A.customization_check ,
A.sort_order ,
A.option_code ,
A.product_id ,
A.image_1 ,
A.image_2 ,
A.MainProductID ,
A.customization_product_id ,
A.inactive ,
A.customization_description ,
A.customization_select ,
A.UOM ,
A.allow_recur ,
A.auto_reorder = CASE --it's an int type column
WHEN A.MainProductID IS NULL THEN A.allow_recur
ELSE B.allow_recur
END
FROM dbo.wc_product_specific A
left outer join wc_product B on B.product_id = A.MainProductID
WHERE A.product_id = 1133