Parsing results from sys.dm_exec_sql_text
There may not be a solution to this, but I was hoping that better minds than mine would have a clue:
Create a table Customer:
create table Customer ([ID] [int] IDENTITY(1,1) NOT NULL,
Name varchar(50),Address varchar(50));
Now populate it with a couple of rows. Next create a View that includes the batch:
create view Customer_view (id, name, address, Text)
as Select id, Name, Address, Text from Customer,
sys.dm_exec_sql_Text((Select sql_handle from sys.sysprocesses where spid = @@spid))
Finally, issue this query:
Select Name,Text from Customer_View where id = 1;
Select Address,Text from Customer_View where id = 1;
go
You will notice that the Text from both Selects is the same, i.e., the full batch:
"Select Name,Text from Customer_View where id = 1; Select Address,Text from Customer_View where id = 1;"
Is there a way to parse the output Text so that it only includes the Text for the specific Select statement. So for example, the Text from the first Select would contain only this:
"Select Name,Text from Customer_View where id = 1;"
and the Text from the second Select would contain only this:
"Select Address,Text from Customer_View where id = 1;"
I don't know if you are still monitoring this thread but I came up with an interesting twist.
Go back to the original table and View from above:
create table Customer ([ID] [int] IDENTITY(1,1) NOT NULL, Name nvarchar(32),Address nvarchar(32));
insert into customer values ('Bertie Wooster', 'London, UK');
create view Customer_view (id, name, address, Text) as
Select id, Name, Address, Text from Customer,
sys.dm_exec_sql_Text((Select sql_handle from sys.sysprocesses where spid = @@spid));
select Name, Address, Text from customer_view where id = 1;
You will see that the result set for Text is the actual query:
select name, address, text from customer_view where id = 1;
Now add this UDF and add it to the View:
create function MyFunc1 (@str nvarchar(32)) returns nvarchar(32) as
begin return upper(@str); end
alter view Customer_view (id, name, address, Text)
as Select id, dbo.MyFunc1(Name), dbo.MyFunc1(Address), dbo.MyFunc1(Text) from Customer,
sys.dm_exec_sql_Text((Select sql_handle from sys.sysprocesses where spid = @@spid))
select Name, Address, Text from customer_view where id = 1;
Now the result set for Text is cut off at the FROM:
SELECT NAME, ADDRESS, TEXT FROM
Any idea what is going on here and how to get the original query?
Thanks.
Similar Messages
-
Invoking a parser class from an applet resulting in exception
I wrote a xml parser to parse a string . Iam parsing the string to the constructor of the parser class . Iam instantiating the parser class from an applet in the java console of the browser the following error is thrown. But instantiating the parser class from a servlet is not possing any issues .Hope to get a reply
java.lang.VerifyError: (class: mediaspan/whiteboard/helper/SvgParser, method: <init> signature: (Ljava/lang/String;)V) Incompatible object argument for function call
at mediaspan.whiteboard.applets.KaleidaPaintFrameAppletReader.chkServer(Unknown Source)
at mediaspan.whiteboard.applets.KaleidaPaintFrameAppletReader.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)hi,
try this in Your code of SvgParser (constructor):
public SvgParser(String strfromapplet) throws SAXException{
// Create a JAXP SAXParserFactory and configure it
SAXParserFactory loSPF = SAXParserFactory.newInstance();
loSPF.setValidating(false);
XMLReader loXMLReader = null;
try{
// Create a JAXP SAXParser
SAXParser loSaxParser = loSPF.newSAXParser();
// Get the encapsulated SAX XMLReader
loXMLReader = loSaxParser.getXMLReader();
// Set the ContentHandler of the XMLReader
loXMLReader.setContentHandler(this);
// Set an ErrorHandler before parsing
loXMLReader.setErrorHandler(this);
try
// Tell the XMLReader to parse the XML document
loXMLReader.parse(strfromapplet);
catch(SAXException se)
System.err.println(se.getMessage());
System.exit(1);
catch(IOException ioe)
System.err.println(ioe);
System.exit(1);
}catch(IOException io){
io.printStackTrace(); -
Hi,
I have table called Employe. And the Columns are Emp_ID,EMP_NAME,SRC_SYS_CD,DOB
I have Query like
Select
COALESCE(MAX(CASE WHEN src_sys_cd='1' THEN Emp_id END), MAX(CASE WHEN src_sys_cd='2' THEN Emp_Id END))Emp_Id,
COALESCE(MAX(CASE WHEN src_sys_cd='1' THEN Emp_name END), MAX(CASE WHEN src_sys_cd='2' THEN Emp_Name END))Emp_name,
COALESCE(MAX(CASE WHEN src_sys_cd='1' THEN dob END), MAX(CASE WHEN src_sys_cd='2' THEN dob END))dob ,
from Employe
group by dob.
I want to generalize the query like get the columns from SYS.ALL_COLUMNS table for that table name and want to pass it to COALEACE() function. I tried with Cursor. But i didnt get the appropriate results.
Is there any way to achieve this? Please help me out in this regard.
Thanks,Is this the kinda thing you're after?
Add a filter to the queries to get just a single table/
WITH allCols AS (
SELECT s.name as sName, o.name AS oName, c.name AS cName, column_id,
CASE WHEN st.name in ('float','bigint','tinyint','int','smallint','bit','datetime','money','date','datetime2','uniqueidentifier','sysname','geography','geometry') THEN st.name
WHEN st.name in ('numeric','real') THEN st.name + '('+CAST(c.scale AS VARCHAR)+','+CAST(c.precision AS VARCHAR)+')'
WHEN st.name in ('varbinary','varchar','binary','char','nchar','nvarchar') THEN st.name + '(' + CAST(ABS(c.max_length) AS VARCHAR) + ')'
ELSE st.name + ' unknown '
END + ' '+
CASE WHEN c.is_identity = 1 THEN 'IDENTITY ' ELSE '' END +
CASE WHEN c.is_nullable = 0 THEN 'NOT ' ELSE '' END + 'NULL' AS bText,
f.name AS fileGroupName
FROM sys.columns c
INNER JOIN sys.objects o
ON c.object_id = o.object_id
AND o.type = 'U'
INNER JOIN sys.systypes st
ON c.user_type_id = st.xusertype
INNER JOIN sys.schemas s
ON o.schema_id = s.schema_id
INNER JOIN sys.indexes i
ON o.object_id = i.object_id
AND i.index_id = (SELECT MIN(index_id) FROM sys.indexes WHERE object_ID = o.object_id)
INNER JOIN sys.filegroups f
ON i.data_space_id = f.data_space_id
), rCTE AS (
SELECT sName, oName, cName, column_id, CAST(cName + ' ' + bText AS VARCHAR(MAX)) as bText, CAST(cName AS VARCHAR(MAX)) AS colList, fileGroupName
FROM allCols
WHERE column_id = 1
UNION ALL
SELECT r.sName, r.oName, r.cName, c.column_id, CAST(r.bText +', ' + c.cName + ' ' +c.bText AS VARCHAR(MAX)), CAST(r.colList+ ', ' +c.cName AS VARCHAR(MAX)), c.fileGroupName
FROM allCols c
INNER JOIN rCTE r
ON c.oName = r.oName
AND c.column_id - 1 = r.column_id
), allIndx AS (
SELECT 'CREATE '+CASE WHEN is_unique = 1 THEN ' UNIQUE ' ELSE '' END+i.type_desc+' INDEX ['+i.name+'] ON ['+CAST(s.name COLLATE DATABASE_DEFAULT AS NVARCHAR )+'].['+o.name+'] (' as prefix,
CASE WHEN is_included_column = 0 THEN '['+c.name+'] '+CASE WHEN ic.is_descending_key = 1 THEN 'DESC' ELSE 'ASC' END END As cols,
CASE WHEN is_included_column = 1 THEN '['+c.name+']'END As incCols,
') WITH ('+
CASE WHEN is_padded = 0 THEN 'PAD_INDEX = OFF,' ELSE 'PAD_INDEX = ON,' END+
CASE WHEN ignore_dup_key = 0 THEN 'IGNORE_DUP_KEY = OFF,' ELSE 'IGNORE_DUP_KEY = ON,' END+
CASE WHEN allow_row_locks = 0 THEN 'ALLOW_ROW_LOCKS = OFF,' ELSE 'ALLOW_ROW_LOCKS = ON,' END+
CASE WHEN allow_page_locks = 0 THEN 'ALLOW_PAGE_LOCKS = OFF' ELSE 'ALLOW_PAGE_LOCKS = ON' END+
')' as suffix, index_column_id, key_ordinal, f.name as fileGroupName
FROM sys.indexes i
LEFT OUTER JOIN sys.index_columns ic
ON i.object_id = ic.object_id
AND i.index_id = ic.index_id
LEFT OUTER JOIN sys.columns c
ON ic.object_id = c.object_id
AND ic.column_id = c.column_id
INNER JOIN sys.objects o
ON i.object_id = o.object_id
AND o.type = 'U'
AND i.type <> 0
INNER JOIN sys.schemas s
ON o.schema_id = s.schema_id
INNER JOIN sys.filegroups f
ON i.data_space_id = f.data_space_id
), idxrCTE AS (
SELECT r.prefix, CAST(r.cols AS NVARCHAR(MAX)) AS cols, CAST(r.incCols AS NVARCHAR(MAX)) AS incCols, r.suffix, r.index_column_id, r.key_ordinal, fileGroupName
FROM allIndx r
WHERE index_column_id = 1
UNION ALL
SELECT o.prefix, COALESCE(r.cols,'') + COALESCE(', '+o.cols,''), COALESCE(r.incCols+', ','') + o.incCols, o.suffix, o.index_column_id, o.key_ordinal, o.fileGroupName
FROM allIndx o
INNER JOIN idxrCTE r
ON o.prefix = r.prefix
AND o.index_column_id - 1 = r.index_column_id
SELECT 'CREATE TABLE ['+sName+'].[' + oName + '] ('+bText+') ON [' + fileGroupName +']'
FROM rCTE r
WHERE column_id = (SELECT MAX(column_id) FROM rCTE WHERE r.oName = oName)
UNION ALL
SELECT prefix + cols + CASE WHEN incCols IS NOT NULL THEN ') INCLUDE ('+incCols ELSE '' END + suffix+' ON [' + fileGroupName +']'
FROM idxrCTE x
WHERE index_column_id = (SELECT MAX(index_column_id) FROM idxrCTE WHERE x.prefix = prefix) -
Hello -
I have the following results from running a SQL_Trace for a session. The first Insert statement uses all bind variables, so it's executed 785 times with 0 missed parses in the Library Cache. The second Insert statement does not use bind variable for two date columns, so this Insert statement is executed anywhere from 1 to 4 times, but there are hundreds of these Insert statements in my trace file. Should performance improve if the second statement uses bind variables for the date columns?
Thanks.
1. Insert statement that uses all bind variables:
insert into SERVICE_EVENT (ACT_UID, SEV_SEQ_NO, RPCS_SOURCE_NM,
SEV_FUNCTION_XX, CLIENT_NM, SEV_HOST_NM, SEV_CICS_TASK_ID, SEV_RECEIVE_TS,
SEV_SEND_TS, SEV_SEND_BYTE_CT, SEV_RECEIVE_BYTE_CT, SEV_G_MESSAGE_XX,
SEV_A_MESSAGE_XX, SERVICE_NM, SEV_SERVER_NM, ORGANIZATION_NM,
APPLICATION_ID, RPC_SEQ_NO)
values
(:1,:2,:3,:4,:5,:6,:7,:8,:9,:10,:11,:12,:13,:14,:15,:16,:17,:18)
call count cpu elapsed disk query current rows
Parse 0 0.00 0.00 0 0 0 0
Execute 785 0.18 0.19 0 681 5210 785
Fetch 0 0.00 0.00 0 0 0 0
total 785 0.18 0.19 0 681 5210 785
2. Insert statement that does not use bind variables for the data columns:
insert into SERVICE_EPISODE (ACT_UID, SE_SERVER_NM, SE_REQ_BYTE_CT,
SE_RESP_BYTE_CT, SE_REQ_XML_XX, SE_RESP_XML_XX, SVX_XML_STYLE_NM,
ORGANIZATION_NM, APPLICATION_CD, CLIENT_REQ_ID, DURATION_MS, STATUS_CD,
SE_REQ_USER_ID, SE_REQ_RACF_IDS, SE_REQ_TS, SE_RESP_TS)
values
(:1,:2,:3,:4,:5,:6,:7,:8,:9,:10,:11,:12,:13,:14,TO_DATE('05/18/05 16:31:17',
'MM/DD/YY HH24:MI:SS'), TO_DATE('05/18/05 16:31:17','MM/DD/YY HH24:MI:SS'))
call count cpu elapsed disk query current rows
Parse 2 0.00 0.00 0 0 0 0
Execute 2 0.00 0.00 0 4 45 2
Fetch 0 0.00 0.00 0 0 0 0
total 4 0.00 0.00 0 4 45 2Should performance improve if the second statement uses bind variables for the date columns? Probably, it depends on how expense the parse is compared to the rest of teh query execution. But generally, if you've got hundreds of statements which are the same except for literals then it's usually a good idea to replace them with a statement that uses bind variables. The best thing to do is benchmark it.
Cheers, APC -
2 differents results with sys.all_objects
select object_name,object_type
from sys.all_objects where owner = 'GROUPE'
and trunc(created) = to_date('12/08/2002','DD/MM/YYYY');
This select statement return 8 rows when running under SQL*Plus but inside a procedure it return 0 row when the procedure is executed, with the same user connected and the same grants.
Can somebody tell me why the same select statement return two different results ?
Thanks !!!
FabriceBarbara is correct in pointing out. You have access to those objects via the roles that have been granted to you.
they work fine in SQL*Plus. But PL/SQL is less forgiving. it does not go through roles assigned to you to
see if you have access to a object or not, it requires explicit grants on the objects directly to the user.
In addition to what Christian said, when executing a procedure, you need to have the rights to select and so forth granted directly, not through a role. -
Hi All,
I want to parse a Name with patterns
You can see the patterns in Name Column. I want the Middle Name has null which has suffix ('JR','SR','II','III','IV','VI','VII','VIII','IX')
<font color="red"> No need to consider after 'AND' / '&' name </font>
Current Table contains in this Format (All Middle_name has Suffix)
Name First_name Middle_name Last_name
AGLIARDI SR THERESA AGLIARDI SR THERESA
ANNE SR SLATON ANNE SR SLATON
ANDREW III UPHOLSTERY & SLIPCOVER ANDREW III UPHOLSTERY
ANGELOZZI JR ORPALT AND CLESTON ANGELOZZI JR ORPALTHelp me guys.......Thanks a lot
Require Table output to be updated as
Name First_name Middle_name Last_name
AGLIARDI SR THERESA AGLIARDI null THERESA
ANNE SR SLATON ANNE NULL SLATON
ANDREW III UPHOLSTERY & SLIPCOVER ANDREW NULL UPHOLSTERY
ANGELOZZI JR ORPALT AND CLESTON ANGELOZZI NULL ORPALTEdited by: Krux_rap on Apr 11, 2012 7:56 PMhi,
it would be helpful if you described your requirements in a more systematical way. Examples are good but never complete.
So try to figure out your rules needed and write them down. After that, try to impement them step by step.
with t as (
select 'ARLIE G WATKINSON JR AND MARYA WATKINSON' s from dual union all
select 'ANTHONY SR - DONNA MARQUEZ' from dual)
first of all you try to get the three parts
select
regexp_replace(s,'([^ ]*)(.*?)([^ ]*$)','\1') first_name
,regexp_replace(s,'([^ ]*)(.*?)([^ ]*$)','\2') middle_name
,regexp_replace(s,'([^ ]*)(.*?)([^ ]*$)','\3') last_name
from t
FIRST_NAME MIDDLE_NAME LAST_NAME
ARLIE G WATKINSON JR AND MARYA WATKINSON
ANTHONY SR - DONNA MARQUEZ
in the next step you apply the rules you need
with t as (
select 'ARLIE G WATKINSON JR AND MARYA WATKINSON' s from dual union all
select 'ANTHONY SR - DONNA MARQUEZ' from dual)
select
regexp_replace(s,'([^ ]*)(.*?)([^ ]*$)','\1') first_name
,case
when -- last_name with leading blank is in middle_name
instr(regexp_replace(s,'([^ ]*)(.*?)([^ ]*$)','\2')
,' '||regexp_replace(s,'([^ ]*)(.*?)([^ ]*$)','\3')
) > 0
then -- take the part before the last_name as middle name
trim(
substr( regexp_replace(s,'([^ ]*)(.*?)([^ ]*$)','\2')
,1
,instr(regexp_replace(s,'([^ ]*)(.*?)([^ ]*$)','\2')
,' '||regexp_replace(s,'([^ ]*)(.*?)([^ ]*$)','\3')
when
regexp_like(s,'JR|SR|II|III|IV|VI|VII|VIII|IX')
then
null
else
regexp_replace(s,'([^ ]*)(.*?)([^ ]*$)','\2')
end middle_name
,regexp_replace(s,'([^ ]*)(.*?)([^ ]*$)','\3') last_name
from t
FIRST_NAME MIDDLE_NAME LAST_NAME
ARLIE G WATKINSON
ANTHONY MARQUEZso now you have to formulate the rule for changing the last_name and the first_name, e.g. is the first name is follow by a comma. After that, we can implement it.
at the kast end, you may optimize the query, e.g. the are shorter ways for the regexp, but i used the verbose versio for demonstration effect.
regards
chris
p.s.
btw, could anyone please explain me how to get a result from toad to copy in a thread which displays the data fitting in the columns they belong to?
Edited by: chris227 on 12.04.2012 01:39
Edited by: chris227 on 13.04.2012 00:46
s instead of ANTHONY SR - DONNA MARQUEZ in the case expression -
Is it possible to have the result from webservices with oracle8i
hi,
i call webservices MS .net with package utl_http under oracle 8i.
exemple:
DECLARE
x utl_http.html_pieces;
msg varchar2(12);
BEGIN
x := utl_http.request_pieces('http://localhost/ServiceNotification/Notification.asmx/NotifT?messagetmp=' || msg);
END;
I don't know how to have a result from a webservices!
thanks for helping me.While the following paper is Oracle9i DB specific, conceptually, what is done should work with Oracle8i.
Bear in mind that the use of XMLType is specific to Oracle9i DB R2 so if you were to follow the example, you would have to use varchars and probably acept the result into the PL/SQL XML Parser. See:
http://otn.oracle.com/tech/webservices/htdocs/samples/dbwebservice/DBWebServices.html
Mike. -
0
SELECT O.Name as ProcName
,M.Definition as CreateScript
,O.Create_Date
,O.Modify_Date
FROM sys.sql_modules as M INNER JOIN sys.objects as O
ON M.object_id = O.object_id
WHERE O.type = 'P'
--Procedure
--WHERE O.type = 'V' View
--WHERE O.type = 'FN' Function
How can I join this to sys.dm_exec_query_stats to
get the execution_count?You can join to sys.dm_exec_procedure_stats using object_id for procedures in cache and get execution count
http://msdn.microsoft.com/en-in/library/cc280701(v=sql.110).aspx
for ones not in cache you need to use logic like below
SELECT O.Name as ProcName
,M.Definition as CreateScript
,O.Create_Date
,O.Modify_Date
,QS.execution_count
FROM sys.dm_exec_query_stats AS QS
CROSS APPLY sys.dm_exec_sql_text(QS.sql_handle) t
INNER JOIN sys.sql_modules as M
ON M.object_id = t.objectid
INNER JOIN sys.objects as O
ON M.object_id = O.object_id
WHERE O.type = 'P'
Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs -
Hi all,
Help me here when i try am unable to get a data,Can some one help me with a query to get.
If it cant be done can i know why..
select * from Sys.databases
where owner_sid='0x01'
What am trying is to get a login
names from syslogin
table with respect to Sid.
Select a.name,b.name,a.owner_sid from Sys.databases a
Join Syslogins b
on a.owner_sid = b.sid
where owner_sid like '0x01'
Thanks all in Advance.....Below are a couple of examples of how to accomplish the task. Note that SID is varbinary so the literal should not be enclosed in quotes.
SELECT
a.name AS DatabaseName
,b.name AS OwnerName
,a.owner_sid AS OwnerSID
FROM sys.databases a
JOIN sys.server_principals b ON
a.owner_sid = b.sid
WHERE owner_sid = 0x01;
SELECT
a.name AS DatabaseName
,SUSER_SNAME(owner_sid) AS OwnerName
,a.owner_sid AS OwnerSID
FROM sys.databases a
WHERE a.owner_sid = 0x01;
Dan Guzman, SQL Server MVP, http://www.dbdelta.com -
Hi,
I want to setup an outpund hybrid search for SharePoint 2013 on-premise to SharePoint Online.
But I'm not shure if this works with ADFS SSO.
Has somebody experience with this setup?
Here's my guide which I'm going to use for this installation:
Introduction
In this post I'll show you how to get search results from your SharePoint Online in your SharePoint 2013 on-premise search center.
Requirements
User synchronisation ActiveDirectory to Office 365 with DirSync
DirSync password sync or ADFS SSO
SharePoint Online
SharePoint 2013 on-premise
Enterprise Search service
SharePoint Online Management Shell
Instructions
All configuration will be done either in the Search Administration of the Central Administration or in the PowerShell console of your on-premise SharePoint 2013 server.
Set up Sever to Server Trust
Export certificates
To create a server to server trust we need two certificates.
[certificate name].pfx: In order to replace the STS certificate, the certificate is needed in Personal Information Exchange (PFX) format including the private key.
[certificate name].cer: In order to set up a trust with Office 365 and Windows Azure ACS, the certificate is needed in CER Base64 format.
First launch the Internet Information Services (IIS) Manager
Select your SharePoint web server and double-click Server Certificates
In the Actions pane, click Create Self-Signed Certificate
Enter a name for the certificate and save it with OK
To export the new certificate in the Pfx format select it and click Export in the Actions pane
Fill the fields and click OK Export to: C:\[certificate
name].pfx Password: [password]
Also we need to export the certificate in the CER Base64 format. For that purpose make a right-click on the certificate select it and click on View...
Click the Details tab and then click Copy to File
On the Welcome to the Certificate Export Wizard page, click Next
On the Export Private Key page, click Next
On the Export File Format page, click Base-64 encoded X.509 (.CER), and then click Next.
As file name enter C:\[certificate
name].cer and then click Next
Finish the export
Import the new STS (SharePoint Token Service) certificate
Let's update the certificate on the STS. Configure and run the PowerShell script below on your SharePoint server.
if(-not (Get-PSSnapin "Microsoft.SharePoint.PowerShell" -ErrorAction SilentlyContinue)){Add-PSSnapin "Microsoft.SharePoint.PowerShell"}
# set the cerficates paths and password
$PfxCertPath = "c:\[certificate name].pfx"
$PfxCertPassword = "[password]"
$X64CertPath = "c:\[certificate name].cer"
# get the encrypted pfx certificate object
$PfxCert = New-Object System.Security.Cryptography.X509Certificates.X509Certificate2 $PfxCertPath, $PfxCertPassword, 20
# import it
Set-SPSecurityTokenServiceConfig -ImportSigningCertificate $PfxCert
Type Yes when prompted with the following message.
You are about to change the signing certificate for the Security Token Service. Changing the certificate to an invalid, inaccessible or non-existent certificate will cause your SharePoint installation to stop functioning. Refer
to the following article for instructions on how to change this certificate: http://go.microsoft.com/fwlink/?LinkID=178475. Are you
sure, you want to continue?
Restart IIS so STS picks up the new certificate.
& iisreset
& net stop SPTimerV4
& net start SPTimerV4
Now validate the certificate replacement by running several PowerShell commands and compare their outputs.
# set the cerficates paths and password
$PfxCertPath = "c:\[certificate name].pfx"
$PfxCertPassword = "[password]"
# get the encrypted pfx certificate object
New-Object System.Security.Cryptography.X509Certificates.X509Certificate2 $PfxCertPath, $PfxCertPassword, 20
# compare the output above with this output
(Get-SPSecurityTokenServiceConfig).LocalLoginProvider.SigningCertificate
[/code]
## Establish the server to server trust
[code lang="ps"]
if(-not (Get-PSSnapin "Microsoft.SharePoint.PowerShell" -ErrorAction SilentlyContinue)){Add-PSSnapin "Microsoft.SharePoint.PowerShell"}
Import-Module MSOnline
Import-Module MSOnlineExtended
# set the cerficates paths and password
$PfxCertPath = "c:\[certificate name].pfx"
$PfxCertPassword = "[password]"
$X64CertPath = "c:\[certificate name].cer"
# set the onpremise domain that you added to Office 365
$SPCN = "sharepoint.domain.com"
# your onpremise SharePoint site url
$SPSite="http://sharepoint"
# don't change this value
$SPOAppID="00000003-0000-0ff1-ce00-000000000000"
# get the encrypted pfx certificate object
$PfxCert = New-Object System.Security.Cryptography.X509Certificates.X509Certificate2 $PfxCertPath, $PfxCertPassword, 20
# get the raw data
$PfxCertBin = $PfxCert.GetRawCertData()
# create a new certificate object
$X64Cert = New-Object System.Security.Cryptography.X509Certificates.X509Certificate2
# import the base 64 encoded certificate
$X64Cert.Import($X64CertPath)
# get the raw data
$X64CertBin = $X64Cert.GetRawCertData()
# save base 64 string in variable
$CredValue = [System.Convert]::ToBase64String($X64CertBin)
# connect to office 3656
Connect-MsolService
# register the on-premise STS as service principal in Office 365
# add a new service principal
New-MsolServicePrincipalCredential -AppPrincipalId $SPOAppID -Type asymmetric -Usage Verify -Value $CredValue
$MsolServicePrincipal = Get-MsolServicePrincipal -AppPrincipalId $SPOAppID
$SPServicePrincipalNames = $MsolServicePrincipal.ServicePrincipalNames
$SPServicePrincipalNames.Add("$SPOAppID/$SPCN")
Set-MsolServicePrincipal -AppPrincipalId $SPOAppID -ServicePrincipalNames $SPServicePrincipalNames
# get the online name identifier
$MsolCompanyInformationID = (Get-MsolCompanyInformation).ObjectID
$MsolServicePrincipalID = (Get-MsolServicePrincipal -ServicePrincipalName $SPOAppID).ObjectID
$MsolNameIdentifier = "$MsolServicePrincipalID@$MsolCompanyInformationID"
# establish the trust from on-premise with ACS (Azure Control Service)
# add a new authenticatio realm
$SPSite = Get-SPSite $SPSite
$SPAppPrincipal = Register-SPAppPrincipal -site $SPSite.rootweb -nameIdentifier $MsolNameIdentifier -displayName "SharePoint Online"
Set-SPAuthenticationRealm -realm $MsolServicePrincipalID
# register the ACS application proxy and token issuer
New-SPAzureAccessControlServiceApplicationProxy -Name "ACS" -MetadataServiceEndpointUri "https://accounts.accesscontrol.windows.net/metadata/json/1/" -DefaultProxyGroup
New-SPTrustedSecurityTokenIssuer -MetadataEndpoint "https://accounts.accesscontrol.windows.net/metadata/json/1/" -IsTrustBroker -Name "ACS"
Add a new result source
To get search results from SharePoint Online we have to add a new result source. Run the following script in a PowerShell ISE session on your SharePoint 2013 on-premise server. Don't forget to update the settings region
if(-not (Get-PSSnapin "Microsoft.SharePoint.PowerShell" -ErrorAction SilentlyContinue)){Add-PSSnapin "Microsoft.SharePoint.PowerShell"}
# region settings
$RemoteSharePointUrl = "http://[example].sharepoint.com"
$ResultSourceName = "SharePoint Online"
$QueryTransform = "{searchTerms}"
$Provier = "SharePoint-Remoteanbieter"
# region settings end
$SPEnterpriseSearchServiceApplication = Get-SPEnterpriseSearchServiceApplication
$FederationManager = New-Object Microsoft.Office.Server.Search.Administration.Query.FederationManager($SPEnterpriseSearchServiceApplication)
$SPEnterpriseSearchOwner = Get-SPEnterpriseSearchOwner -Level Ssa
$ResultSource = $FederationManager.GetSourceByName($ResultSourceName, $SPEnterpriseSearchOwner)
if(!$ResultSource){
Write-Host "Result source does not exist. Creating..."
$ResultSource = $FederationManager.CreateSource($SPEnterpriseSearchOwner)
$ResultSource.Name = $ResultSourceName
$ResultSource.ProviderId = $FederationManager.ListProviders()[$Provier].Id
$ResultSource.ConnectionUrlTemplate = $RemoteSharePointUrl
$ResultSource.CreateQueryTransform($QueryTransform)
$ResultSource.Commit()
Add a new query rule
In the Search Administration click on Query Rules
Select Local SharePoint as Result Source
Click New Query Rule
Enter a Rule name f.g. Search results from SharePoint Online
Expand the Context section
Under Query is performed on these sources click on Add Source
Select your SharePoint Online result source
In the Query Conditions section click on Remove Condition
In the Actions section click on Add Result Block
As title enter Results for "{subjectTerms}" from SharePoint Online
In the Search this Source dropdown select your SharePoint Online result source
Select 3 in the Items dropdown
Expand the Settings section and select "More" link goes to the following URL
In the box below enter this Url https://[example].sharepoint.com/search/pages/results.aspx?k={subjectTerms}
Select This block is always shown above core results and click the OK button
Save the new query ruleHi Janik,
According to your description, my understanding is that you want to display hybrid search results in SharePoint Server 2013.
For achieving your demand, please have a look at the article:
http://technet.microsoft.com/en-us/library/dn197173(v=office.15).aspx
If you are using single sign-on (SSO) authentication, it is important to test hybrid Search functionality by using federated user accounts. Native Office 365 user accounts and Active Directory Domain Services
(AD DS) accounts that are not federated are not recognized by both directory services. Therefore, they cannot authenticate using SSO, and cannot be granted permissions to resources in both deployments. For more information, see Accounts
needed for hybrid configuration and testing.
Best Regards,
Eric
Eric Tao
TechNet Community Support -
How to get save result from EXECUTE from a dynamic SQL query in another table?
Hi everyone,
I have this query:
declare @query varchar(max) = ''
declare @par varchar(10)
SELECT @par = col1 FROM Set
declare @region varchar(50)
SELECT @region = Region FROM Customer
declare @key int
SELECT @key = CustomerKey FROM Customer
SET @query = 'SELECT CustomerKey FROM Customer where ' + @par + ' = '+ @key+ ' '
EXECUTE (@query)
With this query I want get col1 from SET and compare it to the column Region from Customer. I would like to get the matching CustomerKey for it.
After execution it says commands are executed successfully. But I want to save the result from @query in another table. I looked it up and most people say to use sp_executesql. I tried a few constructions as sampled and I would always get this error:
Msg 214, Level 16, State 2, Procedure sp_executesql, Line 12
Procedure expects parameter '@statement' of type 'ntext/nchar/nvarchar'.
So the output should be a list of CustomerKeys in another table.
How can I save the results from EXECUTE into a variable? Then I assume I can INSERT INTO - SELECT in another table.
ThanksCREATE TABLE Customer
(CustomerKey INT , Name NVARCHAR(100));
GO
INSERT dbo.Customer
VALUES ( 1, N'Sam' )
GO
DECLARE @query nvarchar(max) = ''
declare @par varchar(10) = 'Name',
@key varchar(10) = 'Sam'
CREATE TABLE #temp ( CustomerKey INT );
SET @query =
insert #temp
SELECT CustomerKey
FROM Customer
where ' + @par + ' = '''+ @key+ ''' '
PRINT @query
EXEC sp_executesql @query
SELECT *
FROM #temp
DROP TABLE #temp;
DROP TABLE dbo.Customer
Cheers,
Saeid Hasani
Database Consultant
Please feel free to contact me at [email protected] as well as on Twitter and Facebook.
[My Writings on TechNet Wiki] [T-SQL Blog] [Curah!]
[Twitter] [Facebook] [Email] -
Populate report page based on results from stored procedure
Is it possible to populate a report page in APEX based on the results from a stored procedure? If so, how do I do it? Do I write a stored procedure with a ref cursor as out parameter?
I would use a stored procedure to return the values for a form but not for a report. For a
report, I would use a pipelined function. See an example here:
http://htmldb.oracle.com/pls/otn/f?p=31517:146
Denes Kubicek
http://deneskubicek.blogspot.com/
http://htmldb.oracle.com/pls/otn/f?p=31517:1
------------------------------------------------------------------- -
OBIEE Report - filter based on the result from another analysis
Hi,
I am using OBIEE 11g,
I am trying to use a filter which is based on the result from another analysis. I have an analysis A which is as table 1, and I want to filter the respective columns of analysis B (Table B) based on analysis A to remove the duplicates for march 01, 02, and 07 , but it is not working properly. I took a max of start and end time when I created analysis A. Please let me know if I did anything wrong. thanks.
Table 1
Employee Number
Date
IN
Out
Start Time
End Time
xxxxxxx
2015-02-26
9:00
13:00
00:00:00
00:00:00
2015-02-27
12:00
18:00
00:00:00
00:00:00
2015-02-28
8:00
14:00
00:00:00
00:00:00
2015-03-01
14:00
20:00
14:00:00
20:00:00
2015-03-02
16:00
20:00
16:00:00
20:00:00
2015-03-07
14:06
20:02
14:00:00
20:00:00
2015-03-11
16:00
20:00
16:00:00
20:00:00
2015-03-14
8:00
14:00
00:00:00
00:00:00
2015-03-25
14:00
20:00
16:00:00
20:00:00
Table 2
Employee Number
Date
IN
Out
Start Time
End Time
Hours
xxxxxxx
2015-02-26
9:00
13:00
00:00:00
00:00:00
-3
2015-02-27
12:00
18:00
00:00:00
00:00:00
6
2015-02-28
8:00
14:00
00:00:00
00:00:00
6
2015-03-01
14:00
20:00
00:00:00
00:00:00
6
14:00:00
20:00:00
6
2015-03-02
16:00
20:00
00:00:00
00:00:00
4
16:00:00
20:00:00
4
2015-03-07
14:06
20:02
00:00:00
00:00:00
6
14:00:00
20:00:00
6
2015-03-11
16:00
20:00
16:00:00
20:00:00
4
2015-03-14
8:00
14:00
00:00:00
00:00:00
6
2015-03-25
14:00
20:00
16:00:00
20:00:00
4Why avg here?
What columns you want to show in the report?
for a employee for given date if he have 2 rows then you may sum up hours right?
Employee Number
Date
IN
Out
Start Time
End Time
Hours -
How to compare result from sql query with data writen in html input tag?
how to compare result
from sql query with data
writen in html input tag?
I need to compare
user and password in html form
with all user and password in database
how to do this?
or put the resulr from sql query
in array
please help me?Hi dejani
first get the user name and password enter by the user
using
String sUsername=request.getParameter("name of the textfield");
String sPassword=request.getParameter("name of the textfield");
after executeQuery() statement
int exist=0;
while(rs.next())
String sUserId= rs.getString("username");
String sPass_wd= rs.getString("password");
if(sUserId.equals(sUsername) && sPass_wd.equals(sPassword))
exist=1;
if(exist==1)
out.println("user exist");
else
out.println("not exist"); -
Need HELP to pass results from procedure
Hey Gurus,
I need your help. I got a package (test) and inside the package two procedures (step1, step2). Now I want to pass the results from the procedure step1 (stat_rec.lev, stat_rec.chi_sq, stat_rec.chi_sig) to the other procedure step2 and make a select with where-clause. How can I manage this?? Got someone a idea??
Here my package:
CREATE OR REPLACE PACKAGE test1
AS
PROCEDURE step1(table_in IN VARCHAR2, column1 IN VARCHAR2,column2 IN VARCHAR2);
TYPE stat_tab_rec IS RECORD(lev NUMBER, chi_sq NUMBER, chi_sig NUMBER, rank NUMBER);
stat_rec stat_tab_rec;
PROCEDURE step2(table_in IN VARCHAR2, column1 IN VARCHAR2,column2 IN VARCHAR2);
END test1;
Thanks for your help!!
CREATE OR REPLACE PACKAGE BODY test1
AS
PROCEDURE step1(table_in IN VARCHAR2, column1 IN VARCHAR2,column2 IN VARCHAR2,column3 IN VARCHAR2,column4 IN VARCHAR2,column5 IN VARCHAR2)
IS
TYPE cur_crosstab IS REF CURSOR;
cur_cross cur_crosstab;
BEGIN
OPEN cur_cross FOR 'WITH '
||'att_grp AS '
||'(SELECT '||column1||' as x1 , lev AS lev, '||column2||', '
||' CASE'
||' WHEN '||column2||' <= lev '
||' THEN 1 '
||' ELSE 2 '
||'END attribute_group '
||'FROM '||table_in||', '
||'(SELECT level AS lev '
||'FROM dual '
||'WHERE level >= (SELECT MIN('||column2||') FROM '||table_in||') CONNECT BY level <= (SELECT MAX('||column2||') FROM '||table_in||'))) '
||'SELECT lev, '
||'ROUND(STATS_CROSSTAB(x1,attribute_group,''CHISQ_OBS''),4) AS chi_square, '
||'ROUND(STATS_CROSSTAB(x1,attribute_group,''CHISQ_SIG''),4) AS significance, '
||'dense_rank() over (order by ROUND(STATS_CROSSTAB(x1,attribute_group,''CHISQ_OBS'' ),4) DESC) AS rank '
||'FROM att_grp '
||'GROUP BY lev '
||'ORDER BY lev';
LOOP
FETCH cur_cross INTO stat_rec;
EXIT WHEN cur_cross%NOTFOUND;
IF stat_rec.rank = 1 THEN
DBMS_OUTPUT.put_line(column2);
DBMS_OUTPUT.put_line(stat_rec.lev|| ' = ' || TO_CHAR(stat_rec.chi_sq,'99.99') || TO_CHAR(stat_rec.chi_sig,'99.99'));
END IF;
END LOOP;
CLOSE cur_cross;
END step1;
PROCEDURE step2
IS
BEGIN
END step2;
END test1;Thank you Massimo. I tried your example but I recieve an error: PLS-00306: wrong number or types of arguments in call to "procedure1"
Here my Codes:
CREATE OR REPLACE TYPE stat_obj IS OBJECT(zeilen NUMBER,lev NUMBER, chi_sq NUMBER, chi_sig NUMBER);
CREATE OR REPLACE TYPE stat_tab IS TABLE OF stat_obj;
CREATE OR REPLACE PROCEDURE procedure1(table_in IN VARCHAR2,column1 IN VARCHAR2,column2 IN VARCHAR2, v OUT stat_tab)
IS
TYPE cur_crosstab IS REF CURSOR;
cur_cross cur_crosstab;
TYPE stat_tab_rec IS RECORD(lev NUMBER, chi_sq NUMBER, chi_sig NUMBER);
stat_rec stat_tab_rec;
BEGIN
OPEN cur_cross FOR 'WITH '
||'att_grp AS '
||'(SELECT '||column1||' as x1 , lev AS lev, '||column2||', '
||' CASE'
||' WHEN '||column2||' <= lev '
||' THEN 1 '
||' ELSE 2 '
||'END attribute_group '
||'FROM '||table_in||', '
||'(SELECT level AS lev '
||'FROM dual '
||'WHERE level >= (SELECT MIN('||column2||') FROM '||table_in||') CONNECT BY level <= (SELECT MAX('||column2||') FROM '||table_in||'))) '
||'SELECT lev, '
||'ROUND(STATS_CROSSTAB(x1,attribute_group,''CHISQ_OBS''),4) AS chi_square, '
||'ROUND(STATS_CROSSTAB(x1,attribute_group,''CHISQ_SIG''),4) AS significance, '
||'dense_rank() over (order by ROUND(STATS_CROSSTAB(x1,attribute_group,''CHISQ_OBS'' ),4) DESC) AS ranking '
||'FROM att_grp '
||'GROUP BY lev '
||'ORDER BY lev';
LOOP
FETCH cur_cross INTO v;
EXIT WHEN cur_cross%NOTFOUND;
--IF v_stat_tab.rank = 1 THEN
--DBMS_OUTPUT.put_line(v_stat_tab.lev || '=' || TO_CHAR(v_stat_tab.chi_sq,'99.99') || TO_CHAR (v_stat_tab.chi_sig,'99.99'));
--END IF;
END LOOP;
CLOSE cur_cross;
END;
CREATE OR REPLACE PROCEDURE procedure2
IS
v_zeilen NUMBER;
v_lev NUMBER;
v_chi_sq NUMBER;
v_chi_sig NUMBER;
v stat_tab;
BEGIN
procedure1(v);
SELECT zeilen,lev,chi_sq,chi_sig INTO v_zeilen,v_lev,v_chi_sq,v_chi_sig
from table(v);
DBMS_OUTPUT.put_line(v_zeilen||v_lev||v_chi_sq||v_chi_sig);
END;
Hope u can help me!!
Maybe you are looking for
-
Best Practice for utility in Sol Man 4.0
We have software component ST-ICO of release 150_700 with Patch level 5 We want a Template Selection for Utility industry. I checked in the service market place and found that 'Baseline Package United Kingdom V1.50, Template: BP_BLKU150' is availab
-
Client proxy consuming web service provider using logical port issue
Hi All, I have a proxy client having a logical port (configured using NWDS) to consume a web service in the provider system. In the logical port, I have given target address, and logical port name. While moving this client proxy NWDI dev track to Q
-
After reinstalling iTunes continue to get error message r6034 how can we resolve this?
After reinstalling iTunes on my laptop computer, unable to open the program. Continue to get error message r6034 ~ An application has made an attempt to load the C runtime library incorrectly. How can this be resolved?
-
Windows 7 won't connect to bluetooth keyboard
I've been using a Logitech MX5000 keyboard for awhile. I switch between windows and mac via bootcamp all the time. Recently though, I can't use the keyboard while in Windows 7. The keyboard pairs fine, but it is all greyed out. I've tried every sugge
-
Photoshop Elements 12 will not install on Win 8 - fails at "Shared Technologies"
New Lenovo computer with Windows 8.1. Installed Photoshop Premiere Elements 12 w/o a problem. Tried to install Photoshop Elements 12--all went well until it reached "Shared Technologies" and quit the intallation. Troubleshooting info was usless to