SQL SERVER - Ranking Half-Hour Values

Hi!
I'am trying to ranking some table with the following code:
SELECT *
FROM (SELECT distinct 1 as [KPI],
a.Machine_N as [RDP],
Min(a.Date) as [RDP Date],
DATEPART(HOUR,A.Date) AS [RDP TIME],
b.Machine_Name as [RDS],
Min(b.Data) as [RDS Date],
DATEPART(HOUR,b.Data) as [Time],
RANK() OVER 
( PARTITION BY  a.Date  order by b.Data ) as [Rank]
FROM [dbo].[KP1_RDP_SA] a
INNER JOIN [dbo].[KPI1_RDS_SA] b
ON a.Machine_N = b.Machine_Name and DATEPART(hour,a.Date) = DATEPART(hour,b.Data) and CONVERT(Date, a.Date) = Convert(DATE, b.Data) 
WHERE  DATEPART(hour,b.Data) = DATEPART(hour,a.Date) and LEN(a.[Notes]) = 0  and DATEPART(hour,a.Date) > 7 and DATEPART(hour,a.Date) < 20 
GROUP BY a.Date,
b.Data,
a.Machine_N,
b.Machine_Name,b.Data, a.Date
HAVING b.Data > a.Date) tab1
WHERE tab1.Rank = 1
My goal is ranking this value not using DatePart(Hour, Value) but using Half-Hour values, something like that:
RANK() OVER 
( PARTITION BY (DATEPART(hour\2, a.Date))  order by b.Data ) as [Rank]

Thanks for your response.
Here a sample output of my data:
KPI
RDP
RDP Date
Time
RDS
RDS Date
Rank 1
1
PPLRDS01
2015-04-12 08:00:03.000
16
PPLRDS01
2015-04-12 08:00:14.000
1
1
PPLRDS01
2015-04-12 08:30:03.000
17
PPLRDS01
2015-04-12 08:30:13.000
1
1
PPLRDS01
2015-04-12 09:00:03.000
18
PPLRDS01
2015-04-12 09:00:13.000
1
1
PPLRDS01
2015-04-12 09:30:03.000
19
PPLRDS01
2015-04-12 09:30:12.000
1
1
PPLRDS01
2015-04-12 10:00:03.000
20
PPLRDS01
2015-04-12 10:00:15.000
1
1
PPLRDS01
2015-04-12 10:30:03.000
21
PPLRDS01
2015-04-12 10:30:10.000
1
I Have multiples PPLRDS01 in the same space time, and my goal is to ensure that the I only record the first RDP Date at the certain hours and the first half-hour. For example, Imagine that the monitorization registe the following data:
KPI RDP
RDP DATE TIME
RDS DATE
1 PPLRDS01
2015-04-12 08:01:02
        8         2015-04-12 08:01:07
1 PPLRDS01 2015-04-12 08:02:02
8 2015-04-12 08:09:07
1 PPLRDS01 
2015-04-12 08:03:04 8
2015-04-12 08:15:02
1 PPLRDS01
2015-04-12 08:30:02
       8 2015-04-12 08:31:07
1 PPLRDS01 2015-04-12 08:32:02
8 2015-04-12 08:39:07
1 PPLRDS01 
2015-04-12 08:33:04 8
2015-04-12 08:35:02
I only want to save the first half recording data in a half minutes. That's why I create the Rank. To save the first data in a Hour I already do it

Similar Messages

  • [Microsoft][ODBC SQL Server Driver]Invalid character value for cast specifi

    [Microsoft][ODBC SQL Server Driver]Invalid character value for cast specification
    An you help me with this error?
    This is the problemativ query:
    Search QUERY : SELECT DISTINCT theK_files.fileid, theK_files.name, theK_files.t
    itle, theK_files.description, theK_users1.name AS AuthorName, theK_users1.surn
    ame AS AuthorSurname, [theK_file-extensions].name AS Extension, theK_files.publ
    ished, theK_files.updated FROM theK_users INNER JOIN [theK_users-to-groups] ON
    theK_users.userid = [theK_users-to-groups].userid INNER JOIN theK_usergroups
    ON [theK_users-to-groups].groupid = theK_usergroups.groupid INNER JOIN [theK_g
    roups-to-files] ON theK_usergroups.groupid = [theK_groups-to-files].groupid INN
    ER JOIN theK_files ON [theK_groups-to-files].fileid = theK_files.fileid INNER
    JOIN theK_users theK_users1 ON theK_files.authorid = theK_users1.userid INNER
    JOIN [theK_file-extensions] ON theK_files.extensionid = [theK_file-extensions]
    .extensionid WHERE theK_users.userid = '1' AND theK_files.extensionid = '1' AN
    D ( theK_files.name LIKE '%a%' OR theK_users1.name LIKE '%a%' OR theK_files.de
    scription LIKE '%a%' )

    are these columns character/string/varchar:
    theK_users.userid = '1'
    theK_files.extensionid = '1'
    if these are number columns, change them to
    theK_users.userid = 1
    theK_files.extensionid = 1
    Jamie

  • Crystal Reports 9 and SQL Server 2005 default parameter values

    We're using Crystal Reports 9 and upgraded from SQL Server 2000 to SQL Server 2005.
    I'm noticing a very weird problem which I wonder if anyone else has experienced (and hopefully found a resolution for). It appears that in using Crystal with SQL Server 2005 stored procedures, if we have default parameter values in the stored procedures, the default parameter values get completely ignored if you pass in a NULL value from Crystal!
    For example, if you have a stored procedure that begins like this:
    ALTER          Procedure [dbo].[StoredProcedure]
    @Param1 VarChar(200) = '',
    @Param2 VarChar(200) = ''
    AS ...
    both @Param1 and @Param2 have a default value of an empty string, and therefore should become empty strings if nothing (NULL values) gets passed in for them.
    But, like I said, what I'm finding is that with Crystal calling the stored procedure with NULL @Param1 and @Param2 values, they never become empty strings, but rather remain as NULLs.
    This was never a problem with SQL 2000.
    Very perplexing. Anyone else every experience this?
    Thank you.

    Please ignore my earlier post -- answered my own question.
    NULL parameter values do not get replaced by default values in SQL -- that is normal behavior in both SQL 2000 and SQL 2005. Just goes to show, that no many how many years programming experience you have, you can still get tripped up sometimes : (

  • SQl Server - cant compare with values in table field have nchar as datatype

    Hello all!
    I am using jtds driver to connect with SQL server. My problem is i am saving arabic text into the SQL Server. The fields which contains arabic text have the datatype nchar. I can insert the values by simply placing N before the actual arabic text which i am reading from a file.
    I mean insert into [table] values(N'some arabic text') works fine.
    But when i try to select the values from the table and want to pass some paramerts (in arabic text) in where clause it doesnt return me anything.
    e.g select * from [table] where [column(nchar type)] = N'arabic text(read from file)' return nothing. Result set is always empty.
    Queryis fine as i printed the query in seperate file and run it on Query analyzer which gives me the right results.
    Any suggestions?? Please i am dying conditions tell me any solutions immediately
    Regards,
    Alam sher

    String url = "............";
    Properties props = new Properties();
    props.put("charset","cp1256");
    Connection con = DriverManager.getConnection(url,props);now this way if i get the resultset it would return me the expected resultset:)
    To compare an arabic word against the values in result set one also has to convert it into cp1256 encoding line this.
    new String([arabic word].getBytes(), "cp1256");
    The prolem was not to print the arabic words on console basically. No doubt on console it would print ???? as it doesnot support this encoding. Originial issu was comparing a string containig the arabic text with the values returned by the result set.
    This was the solution i could figure out and its working.
    Thanks anyways.
    Regards,
    Alam Sher

  • Ident_Current('TableName') not giving last inserted identity Value in SQL Server 2012

    Hi ,
    Ident_Current('TableName') is not giving last inserted identity Value in SQL Server 2012. 
    Latest Value of ID and Ident_Current is differing for that particular table.  
    Why its happening? Ident_Current value is greater than last inserted ID.
    Please guide me why its happening?

    Here is one example:
    CREATE DATABASE PMCtest ON (NAME = 'PMCtest', FILENAME = 'B:\ProdDB-Unzipped\PMCtest.mdf', SIZE = 25GB )
    LOG ON (NAME = 'PMCtest_log', FILENAME = 'B:\ProdDB-Unzipped\PMCtest.ldf', SIZE = 2GB)
    CREATE TABLE identity_crisis (a int IDENTITY NOT NULL PRIMARY KEY,
                                  b sysname NOT NULL CHECK (b <> 'sysschobjs'))
    go
    INSERT identity_crisis (b) VALUES ('First name')
    INSERT identity_crisis SELECT name FROM sys.objects
    go
    SELECT MAX(a), ident_current('identity_crisis')
    FROM  identity_crisis
    go
    DROP TABLE identity_crisis
    Because the second INSERT statement fails, the identity values from 2 to 12 are lost. This is a very intentional design to promote high concurrency. If you don't want gaps, you should not use IDENTITY, but roll your own.
    Also, beware that ident_current returns database-wide value, so if you insert one row, and another process inserts another row before you interrogate ident_current, you will get the id for the row of the other process.
    Erland Sommarskog, SQL Server MVP, [email protected]

  • Problem with provisioning and external SQL server connection

    I am configuring IPAM 2012 R2 on a our management server.  Completed the first step by enabling the feature.  No issues.
    Now I am on the Provisioning IPAM step.  I get to the Configure Database step...
    I choose Microsoft SQL server,
    What should those values be in the Server name and Database name fields.  Instructions show fqdn or ip address but that doesnt seem to be working for me.
    I get the following error at the end of the Provisioning IPAM wizard,
    IPAM Deployment failed with the following error.
    Failed to connect to database server. Check the database name, connectivity and remote access.
    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: TCP Provider, error: 0 - No connection could be made because the target machine actively refused it.)
    You can restart this provisioning wizard from the IPAM overview page.
    From the management server I have tested the SQL Connection with a udl file.  I used myServer\myInstance and it works.  It reports that I have made the Connection to the server and database with the sql credentials i have provided.
    Thanks

    Ran
    into a problem with connecting to the DB on the SQL server from the IPAM server.  The Dba and I checked the target SQL instance was enabled TCP and listening on a valid TCP port.  SQL server was set to use port 1443 for incoming connections. 
    IPAM was set by default to use 1433. 
    Also used
    netstat-n to identify issue and verified 1443 on SQL server was
    being used.  Made the correction under the IPAM provisioning wizard and connected to the database.  Fixed. 
    Important note I was able to connect to the database with a .udlfile
    without any issues
    Also note that 2012 R2 IPAM only supports 2012 SQL Enterprise.  Why?

  • Bad query plan for self-referencing CTE view query and variable in WHERE clause. Is there way out or this is SQL Server defect?

    Please help. Thank you for your time and expertise.
    Prerequisites: sql query needs to be a view. Real view is more than recursion. It computes location path,  is used in JOINs and returns this path.
    Problem: no matter what I tried, sql server does not produce 'index seek' when using variable but does with literal.
    See full reproduction code below.
    I expect that query SELECT lcCode FROM dbo.vwLocationCodes l WHERE l.lcID = @lcID will seek UNIQUE index but it does not.
    I tried these:
    1. Changing UX and/or PK to be CLUSTERED.
    2. query OPTION(RECOMPILE)
    3. FORCESEEK on view
    4. SQL Server 2012/2014
    5. Wrap it into function and CROSS APPLY. On large outer number of rows this just dies, no solution
    but to no avail. This smells like a bug in SQL Server. I am seeking your confirmation.
    I am thinking it is a bug as variable value is high-cardinality, 1, and query is against unique key. This must produce single seek, depending if clustered or nonclustred index is unique
    Thanks
    Vladimir
    use tempdb
    BEGIN TRAN
    -- setup definition
    CREATE TABLE dbo.LocationHierarchy(
    lcID int NOT NULL ,
    lcHID hierarchyid NOT NULL,
    lcCode nvarchar(25) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
    lcHIDParent AS lcHID.GetAncestor(1) PERSISTED,
    CONSTRAINT PK_LocationHierarchy_lcID PRIMARY KEY NONCLUSTERED (lcID ASC),
    CONSTRAINT UX_LocationHierarchy_pltID_lcHID UNIQUE CLUSTERED (lcHID ASC)
    -- add some data
    INSERT INTO dbo.LocationHierarchy
    VALUES
    (1, '/', 'A')
    ,(2, '/1/', 'B')
    ,(3, '/1/1/', 'C')
    ,(4, '/1/1/1/', 'D')
    --DROP VIEW dbo.vwLocationCodes
    GO
    CREATE VIEW dbo.vwLocationCodes
    AS
    WITH ru AS
    SELECT
    lh.lcID
    ,lh.lcCode
    ,lh.lcHID
    ,CAST('/' + lh.lcCode + '/' as varchar(8000)) as LocationPath
    -- to support recursion
    ,lh.lcHIDParent
    FROM dbo.LocationHierarchy lh
    UNION ALL
    SELECT
    ru.lcID
    ,ru.lcCode
    ,ru.lcHID
    ,CAST('/' + lh.lcCode + ru.LocationPath as varchar(8000)) as LocationPath
    ,lh.lcHIDParent
    FROM dbo.LocationHierarchy lh
    JOIN ru ON ru.lcHIDParent = lh.lcHID
    SELECT
    lh.lcID
    ,lh.lcCode
    ,lh.LocationPath
    ,lh.lcHID
    FROM ru lh
    WHERE lh.lcHIDParent IS NULL
    GO
    -- get data via view
    SELECT
    CONCAT(SPACE(l.lcHID.GetLevel() * 4), lcCode) as LocationIndented
    FROM dbo.vwLocationCodes l
    ORDER BY lcHID
    GO
    SET SHOWPLAN_XML ON
    GO
    DECLARE @lcID int = 2
    -- I believe this produces bad plan and is defect in SQL Server optimizer.
    -- variable value cardinality is 1 and SQL Server should know that. Optiomal plan is to do index seek with key lookup.
    -- This does not happen.
    SELECT lcCode FROM dbo.vwLocationCodes l WHERE l.lcID = @lcID -- bad plan
    -- this is a plan I expect.
    SELECT lcCode FROM dbo.vwLocationCodes l WHERE l.lcID = 2 -- good plan
    -- I reviewed these but I need a view here, can't be SP
    -- http://sqlblogcasts.com/blogs/tonyrogerson/archive/2008/05/17/non-recursive-common-table-expressions-performance-sucks-1-cte-self-join-cte-sub-query-inline-expansion.aspx
    -- http://social.msdn.microsoft.com/Forums/sqlserver/en-US/22d2d580-0ff8-4a9b-b0d0-e6a8345062df/issue-with-select-using-a-recursive-cte-and-parameterizing-the-query?forum=transactsql
    GO
    SET SHOWPLAN_XML OFF
    GO
    ROLLBACK
    Vladimir Moldovanenko

    Here is more... note that I am creating table Items and these can be in Locations.
    I am trying LEFT JOIN and OUTER APLLY to 'bend' query into NESTED LOOP and SEEK. There has to be nested loop, 2 rows against 4. But SQL Server fails to generate optimal plan with SEEK. Even RECOMPILE does not help
    use tempdb
    BEGIN TRAN
    -- setup definition
    CREATE TABLE dbo.LocationHierarchy(
    lcID int NOT NULL ,
    lcHID hierarchyid NOT NULL,
    lcCode nvarchar(25) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
    lcHIDParent AS lcHID.GetAncestor(1) PERSISTED,
    CONSTRAINT PK_LocationHierarchy_lcID PRIMARY KEY NONCLUSTERED (lcID ASC),
    CONSTRAINT UX_LocationHierarchy_pltID_lcHID UNIQUE CLUSTERED (lcHID ASC)
    -- add some data
    INSERT INTO dbo.LocationHierarchy
    VALUES
    (1, '/', 'A')
    ,(2, '/1/', 'B')
    ,(3, '/1/1/', 'C')
    ,(4, '/1/1/1/', 'D')
    --DROP VIEW dbo.vwLocationCodes
    GO
    --DECLARE @Count int = 10;
    --WITH L0 AS (SELECT N FROM (VALUES(1),(1),(1),(1),(1),(1),(1),(1),(1),(1)) N (N))-- 10 rows
    --,L1 AS (SELECT n1.N FROM L0 n1 CROSS JOIN L0 n2) -- 100 rows
    --,L2 AS (SELECT n1.N FROM L1 n1 CROSS JOIN L1 n2) -- 10,000 rows
    --,L3 AS (SELECT n1.N FROM L2 n1 CROSS JOIN L2 n2) -- 100,000,000 rows
    --,x AS
    -- SELECT TOP (ISNULL(@Count, 0))
    -- ROW_NUMBER() OVER (ORDER BY (SELECT NULL)) as Number
    -- FROM L3 n1
    --SELECT Number as itmID, NTILE(4)OVER(ORDER BY Number) as lcID
    --INTO dbo.Items
    --FROM x
    ----ORDER BY n1.N
    --ALTER TABLE dbo.Items ALTER COLUMN itmID INT NOT NULL
    --ALTER TABLE dbo.Items ADD CONSTRAINT PK PRIMARY KEY CLUSTERED (itmID)
    CREATE TABLE dbo.Items (itmID int NOT NULL PRIMARY KEY, lcID int NOT NULL)
    INSERT INTO dbo.items
    VALUES(1, 1)
    ,(2, 3)
    GO
    CREATE VIEW dbo.vwLocationCodes
    AS
    WITH ru AS
    SELECT
    lh.lcID
    ,lh.lcCode
    ,lh.lcHID
    ,CAST('/' + lh.lcCode + '/' as varchar(8000)) as LocationPath
    -- to support recursion
    ,lh.lcHIDParent
    FROM dbo.LocationHierarchy lh
    UNION ALL
    SELECT
    ru.lcID
    ,ru.lcCode
    ,ru.lcHID
    ,CAST('/' + lh.lcCode + ru.LocationPath as varchar(8000)) as LocationPath
    ,lh.lcHIDParent
    FROM dbo.LocationHierarchy lh
    JOIN ru ON ru.lcHIDParent = lh.lcHID
    SELECT
    lh.lcID
    ,lh.lcCode
    ,lh.LocationPath
    ,lh.lcHID
    FROM ru lh
    WHERE lh.lcHIDParent IS NULL
    GO
    -- get data via view
    SELECT
    CONCAT(SPACE(l.lcHID.GetLevel() * 4), lcCode) as LocationIndented
    FROM dbo.vwLocationCodes l
    ORDER BY lcHID
    GO
    --SET SHOWPLAN_XML ON
    GO
    DECLARE @lcID int = 2
    -- I believe this produces bad plan and is defect in SQL Server optimizer.
    -- variable value cardinality is 1 and SQL Server should know that. Optiomal plan is to do index seek with key lookup.
    -- This does not happen.
    SELECT lcCode FROM dbo.vwLocationCodes l WHERE l.lcID = @lcID-- OPTION(RECOMPILE) -- bad plan
    -- this is a plan I expect.
    SELECT lcCode FROM dbo.vwLocationCodes l WHERE l.lcID = 2 -- good plan
    SELECT *
    FROM dbo.Items itm
    LEFT JOIN dbo.vwLocationCodes l ON l.lcID = itm.lcID
    OPTION(RECOMPILE)
    SELECT *
    FROM dbo.Items itm
    OUTER APPLY
    SELECT *
    FROM dbo.vwLocationCodes l
    WHERE l.lcID = itm.lcID
    ) l
    -- I reviewed these but I need a view here, can't be SP
    -- http://sqlblogcasts.com/blogs/tonyrogerson/archive/2008/05/17/non-recursive-common-table-expressions-performance-sucks-1-cte-self-join-cte-sub-query-inline-expansion.aspx
    -- http://social.msdn.microsoft.com/Forums/sqlserver/en-US/22d2d580-0ff8-4a9b-b0d0-e6a8345062df/issue-with-select-using-a-recursive-cte-and-parameterizing-the-query?forum=transactsql
    GO
    --SET SHOWPLAN_XML OFF
    GO
    ROLLBACK
    Vladimir Moldovanenko

  • RE:ora-28500 when trying to insert into SQL Server table

    Hi all!
    I'm getting this when i attempt to insert into my table test in a SQL Server database. As u can see from the select, the database link seems ok. Any ideas plz. Thnx..
    SQL> select "idAges" from test@try2;
    no rows selected
    SQL> insert into test@try2 ("idAges","nARAges","nAPAges") values(10,'','');
    insert into test@try2 ("idAges","nARAges","nAPAges") values(10,'','')
    ERROR at line 1:
    ORA-28500: connection from ORACLE to a non-Oracle system returned this message:
    [Generic Connectivity Using ODBC][Microsoft][ODBC SQL Server Driver][SQL
    Server]Cannot insert explicit value for identity column in table 'test' when
    IDENTITY_INSERT is set to OFF. (SQL State: 23000; SQL Code: 544)
    ORA-02063: preceding 2 lines from TRY2

    IDENTITY_INSERT on works only for particular session and for one table. It's not global variable.
    The only idea what I have is to create link from MS Sql to Oracle (right now You have oracle ->ms sql)and then before insert You will set identity_insert on and will run insert.

  • Best practice for saving data in SQL server

    Hi all
    Hoping for a little help on this question. 
    If i have a list of fields ex. (name,address,postal,phone etc.). Then i create a webform/task
    to gather some of theese fields (name, postal), then i make another webform/task to gather some other fields (address, phone). 
    What is best practice in the SQL server for storing returning values.
    Is it: 
    1. to make a table with all the fields in the list + taskid. Theese fields could be in
    correct format (number, date etc.). And all answers to all tasks is inserted into this table. 
    2. Make a value table for each field with the correct type + task id. So all name values
    are stored in the "name value table" with the task id.
    How would i select values from a certain task from this kind of setup?
    3. ??
    Best regards
    Bo

    Hi Atul
    Thanks for your reply, can you elaborate a bit further on this, since i am still a little confused. 
    Let me try to explain my scenario at bit more:
    Say instead that it is 50 fields in a table with their own unique ID, maybe an answer table
    would look like this:
    taskid | field_1 | field_2 | field_3 | field 4 | field_n
    So no matter which fields the user fillsout it will can be stored in one table. 
    QUestion is, is this a good way to do it? and how do i select from this table using a join
    As far as i know you cant name columns in a table with just numbers, which would have been
    great, giving the columnnames the field_id.
    OR
    Would you have 50 tables each with a field_id and a value (of correct type) ?
    And could you give me an example of how to bind and select from this kind of structure ?
    Also inserting into 50 tables on a save.... is that the right way to go? :)
    Best regards
    Bo

  • How to insert into SQL server table form oracle forms

    I created a form with oracle as my database. But there one trigger where I need to insert the data into a sql server table.
    Is this possible. If so can any help me out.
    Thanks in advance.
    Asha

    Hi,
    You can insert into sql server database using the following steps
    Note: Check wether you are using Forms 32 bit drivers. If not the Odbc data source will not work.
    step 1: Create ODBC data source for SQL server(one time creation);
    step 2: Logout from Oracle and login to SQL server giving the user name,password and host string as odbc:<odbc datasource name>;
    step 3: use EXEC SQL statement to insert the values into the SQL server and then logout and login again to your oracle database.
    Second Method.
    Check the sql server documentation to insert the values using command line parameters. Then you can call the host command to execute this.
    Third Method.
    Write a VB exe to enter the values in the sql server making two connections one to oracle another to SQL server and then getting values from Oracle and putting in the SQL server database. You can call this exe using the Host command.
    Hope this will help You.
    Regards
    Gaurav Thakur

  • Count of NULL field from SQL Server

    Hi All,
    OBIEE 11g
    I have a requirement to count the number of rows from a table in SQL Server that has NULL values in that particular field. In the BMM I have placed a metric called Total Count and the aggregation for this is Count. The case statement I have in the BMM is as follows.
    CASE <FIELD TO COUNT>
    WHEN NULL THEN 1
    WHEN ' ' THEN 1
    ELSE 0
    I am not getting the correct results for this count.

    Try this
    sum(
    CASE WHEN COL is null or COL =' ' or COL ='' THEN 1 ELSE 0 END)
    If you count 0 also counting.
    Pls mark as correct/helpful if helps

  • SQL Command code for multiple value string parameter

    Hi,
    I'm using crystal 2008 and there is a check box for multiple value  SQL Command  I need some help in writing the SQL Command code  for oracle (or sql server) for a multiple value STRING  parameter.
    Thanks in advance,
    Marilyn

    I could be wrong here, but I do not believe you can pass a multiple valued parameter to an SQL Command data source.  How I have gotten around this in the past is to put the "real" report into a subreport.  In the main report, create a formula field (basic syntax):
    formula = join({?parameter}, "|")
    Then, use this to pass the selected values to the subreport's parameter (call it {?sr-parm}).  The SQL Command in the subreport can then use that (MS SQL):
    select *
    from table
    where charindex(table.field, '{?sr-parm}') > 0
    HTH,
    Carl

  • SQL Server runs update on one record, returns -1 records updated to java

    I am trying to troubleshoot an issue in SQL Server. For all the databases in a specific server, the return value for java initiated update statements have completed the update (ie. I can go into SQL Server and verify the values have changed), but returned
    a value of -1 records updated. I am not sure what went wrong to cause this to fail. It works on one server, but not on any databases on the other server and it suddenly changed on Friday, April 10. Here is the results of the java I am running.
    Driver vendor: Microsoft JDBC Driver 4.0 for SQL Server
    DriverVersion: 4.0.4621.201
    dbproduct: Microsoft SQL Server
    JavaPlus Connection Made: no warnings
    Executing :update maxsequence set maxreserved = 401 where sequencename ='SERVERSESSIONSEQ' and maxreserved=400
    Using TYPE_SCROLL_INSENSITIVE
    Execute Returned -- (boolean) --- false
    Execute getUpdateCount -- (num) -1
    Execute took :0(15) secs.
    Update/Deleted :-1 records.
    Fetching/Updating took :0(0) secs.
    I am runnning SQL Server 2012 and Windows 2012R2
    Microsoft SQL Server Management Studio 11.0.2100.60
    Microsoft Analysis Services Client Tools
    11.0.2100.60
    Microsoft Data Access Components (MDAC) 6.3.9600.16384
    Microsoft MSXML 3.0 4.0 6.0 
    Microsoft Internet Explorer 9.11.9600.16518
    Microsoft .NET Framework 4.0.30319.34011
    Operating System 6.3.9600

    Can you clarify why your Java output saying Execute Returned -- (boolean) --- false
    I suspect this update never happened and it is possible to get updated row counts such as by using stored
    procedure and returning @@ROWCOUNT value through return statement to the data set
    Would you like to try this?
    Good Luck! Please Mark This As Answer if it solved your issue. Please Vote This As Helpful if it helps to solve your issue

  • SQL query to store float values in french culture.

    Here is how my requirement goes..
    I have an application where users can store float values into the SQL server. Here float values are period(.) based. I have now started supporting the users who use the french culture where the float values are Comma(,) based. Example: 13.75 is represented
    as 13,75. Instead of making changes to my code i.e the way i am inserting/retrieving the date now, is there a way i can handle this requirement based on culture. Like, if I specify the culture, will I be able to insert float inputs as comma(,) based values
    without disturbing my existing code?
    Any help is appreciated
    Thanks,
    Chandrahas.
    -Chandrahas

    is there a way i can handle this requirement based on culture.
    Hello Chandrahas,
    SQL Server don't store any culture info for numeric values; they are plain numeric.
    It's part of the frontend to represent / accept values depending on the culture setting of the client.
    Olaf Helper
    [ Blog] [ Xing] [ MVP]

  • How to connect musicdb to Microsoft SQL Server

    hi..
    i have tried musicdb example with mysql, but i need to connect it to SQL Server.
    i have created a similar DB in SQL SERVER, however i am not able to create a user, similar to musicdbuser and musicdbpass in SQL SERVER.
    Also in the Administrator console i followed these steps.
    1. Applications->web Applications->deployed the war file-> OK
    2.Resources->JDBC->Connection Pool->New->Name ='musicdb-jdbc-pool-SQLserver'->Resource Type='javax.sql.Datasource'->Database Vendor='Microsoft SQL SERVER'-> Next
    added properties Values
    databaseName musicdb(this is the database i created in MS SQL SERVER)
    databaseSourceName musicdb(this is the DSN name i created in control panel->ODBC connections)
    networkProtocol TCP
    user sa (this is the username that i use to start SQL SERVER)
    password syntel123$ (this is the password that i use with the above user )
    portNumber 1443
    serverName localhost
    then i click finish.
    if i say ping to this connection , i get success!!
    3. then i goto resources->jdbc->jdbc resources->new->JNDI Name="jdbc/musicdb"->pool name="musicdb-jdbc-pool-SQLserver'"->ok
    4. Then i click resources->connectors->connector connection pool->new->Name="mep/musicdb"->resource adapter="ds-jcr-connector-jaxrs"->next->finish
    5 Then i click resources->connector resources->new->JNDI name="mep/musicdb"->pool="mep/musicdb"->ok
    however when i hit the URL http://localhost:8080/musicdb/resources/albums
    i get the following error
    type : Exception report
    message
    description: The server encountered an internal error () that prevented it from fulfilling this request.
    exception: javax.servlet.ServletException: com.sun.jersey.api.container.ContainerException: java.lang.NoClassDefFoundError: Could not initialize class com.sun.mep.ws.vtms.util.ConnectionPool
    root cause: com.sun.jersey.api.container.ContainerException: java.lang.NoClassDefFoundError: Could not initialize class com.sun.mep.ws.vtms.util.ConnectionPool
    root cause: java.lang.NoClassDefFoundError: Could not initialize class com.sun.mep.ws.vtms.util.ConnectionPool

    Hi,
    I was able to create a JDBC connection pool for SQL Server successfully and will share the key steps, and was able to create a MEP user with an ECBO connection configured for the SQL Server; However, it looks like there is a "false positive" problem. Even though the user was created with the SQL Server connector whose associated JDBC connection pool passed the Ping test, doing a sync as that user changed the MySQL database album table and not the SQL Sever album table. MEP didn't give any error at all. I will bring this up with our engineers.
    Here are the steps for at least getting GF JDBC connections with SQL Server working.
    1. With MS SQL Sever 2005 Server Management Studio,
    created a 'musicdb' database, a 'musicdbuser' user with password 'musicdbpass',
    and added the 'album' table with
    name (varchar(30) primary key, not null)
    artist (varchar(30), not null)
    date_published (datetime, not null)
    rating (int, not null)
    username (varchar(30), not null)
    2. With MS SQLServer Configuration Manager, enable TCP/IP on static IP address
    and 127.0.0.1 on port 1433 and restarted the SQL Server service
    3. Downloaded Microsoft's 2.0 Driver for SQL Server 2005
    4. Copied the driver sqljdbc4.jar to GF_HOME/domains/mep/lib/ext
    5. Restarted GF
    6. Login to GF Admin Console
    7. Create Resources -> JDBC -> Connection Pool
    name: musicdb_pool_sqlserver
    resource type: javax.sql.DataSource
    datasource class: com.microsoft.sqlserver.jdbc.SQLServerDataSource
    8. Create Resources -> JDBC -> Resource
    name jdbc/musicdb_sqlserver
    9. Go back to musicdb_pool_sqlserver and click Additional Properties then add
    user: musicdbuser
    password: musicdbpass
    serverName=localhost
    portNumber=1433
    databaseName=musicdb
    10. Click General tab and click Ping. Get Success!

Maybe you are looking for

  • Just installed itunes on windows 8 and can't open it

    Have purchased a new computer with Windows 8.  Have just installed itunes on it and now it will not let me open it!!  Please help

  • Embeded videos in keynote don't play when exported as a quicktime movie

    I have a keynote presentation with videos in it. I want to export it as a QuickTime movie but when I do the videos do not play. What do I need to do to resolve this?

  • Icons changed - how do I change them back?

    Hi guys, Quick question - I had a problem while copying a file to a flash disk and Finder crashed (hard to believe, yes). So I force-quitted it but it didn't restart so I restarted the computer by holding down the power button. Then when I started it

  • Burning to MP3 Continued,

    Continuation from previously asked question about AAC files. Should of said, does it matter that i've got an ipod shuffle second generation is that the reason my itunes has chosen and continues to choose AAC as the recording option. And how do i chan

  • How to view the code in MV5AFZZ

    hi, i want to view a code from user exit MV45AFZZ, because i have to restrict list of customers basing on account group and sales area. regards, balaji