How to convert the following query to sql server 2005

hi
i have the following query in ms access and i want to convert it into sql server 2005 express edition
SELECT iif(Max(BNo) is null,1,Max(BNo)+1) AS BNo from ( SELECT iif(Max(Product.BNo) is null,0,Max(Product.BNo)) AS BNo FROM Product union all SELECT iif(Max(grndetail.BNo) is null,0,Max(grndetail.BNo)) AS BNo FROM grndetail UNION ALL SELECT iif(Max(srdetail.BNo) is null,0,Max(srdetail.BNo)) AS BNo FROM srdetail ) as t
how to do this

The construct involving case when MAX sounds suspicious. Can you explain what the query is supposed to be doing, the structure of your table, then we can re-write it?
E.g. if you provide your table, some data and desired result, you'll get better answer than direct translation of this suspicious query.
For every expert, there is an equal and opposite expert. - Becker's Law
My blog
My TechNet articles

Similar Messages

  • How to restore the Password backup in sql server 2005

    How to restore the Password backup in sql server 2005

    Hello,
    THANKS............ BUT
    I executed this query 
    RESTORE DATABASE new_data1
    FROM DISK = 'd:\UK_DETAILS.bak'
    with password ='selfinity123'
    WITH MOVE 'UK_DETAILS.bak' TO 'D:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\new_data1.mdf',
    MOVE 'UK_DETAILS.bak' TO 'D:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\new_data1.ldf'
    I got the error 
    Msg 319, Level 15, State 1, Line 4
    Incorrect syntax near the keyword 'with'. If this statement is a common table expression or an xmlnamespaces clause, the previous statement must be terminated with a semicolon.

  • How to set the CLASSPATH for an  Sql Server 2005 database... help me please

    Hello! Guys I want to access a Sql Server 2005 database from Java.I've downloaded the JDBC 2.0 driver from Microsoft.I've copied the sqljdbc4.jar file to C:\Java\jdk1.6.0_14\db\lib.And I've added this to the classpath C:\Java\jdk1.6.0_14\db\lib\sqljdbc4.jar.The classpath variable is defined as a user variable.Well the point is that I get that nasty exception:Exception in thread "main" java.lang.ClassNotFoundException: com.microsoft.sqlserver.jdbc.SQLServerDriver.So if you know how to help me,please do so.Thank you :)

    Hi Timo,
    My jdev version is 10.1.3.3.0, this is for R12. By PR i mean to say process request and PFR process form request in the controller.
    In the Process request of the controller, i am finding the checkbox bean and assigning the firepartialaction for it.
    Later in the process form request for the fired event, i am trying to handle the rendered property of the messagetextinput. Is this a right approach?
    my code below
    public void processRequest(OAPageContext oapagecontext, OAWebBean oawebbean)
    super.processRequest(oapagecontext, oawebbean);
    OAApplicationModule oaapplicationmodule = oapagecontext.getApplicationModule(oawebbean);
    OAMessageCheckBoxBean oamessagecheckboxbean = (OAMessageCheckBoxBean)oawebbean.findChildRecursive("X_FLAG");
    if(oamessagecheckboxbean != null)
    oapagecontext.writeDiagnostics(this, "Message check box Bean found:", 1);
    FirePartialAction firepartialaction = new FirePartialAction("change");
    oamessagecheckboxbean.setAttributeValue(PRIMARY_CLIENT_ACTION_ATTR, firepartialaction);
    oamessagecheckboxbean.setFireActionForSubmit("change", null, null, true);
    oapagecontext.writeDiagnostics(this, "setting fire event", 1);
    public void processFormRequest(OAPageContext oapagecontext, OAWebBean oawebbean)
    super.processFormRequest(oapagecontext, oawebbean);
    oapagecontext.writeDiagnostics(this, "Inside Process Form Request", 1);
    if("change".equals(oapagecontext.getParameter(OAWebBeanConstants.EVENT_PARAM)))
    OAMessageTextInputBean bean = (OAMessageTextInputBean)oawebbean.findChildRecursive("X_NUMBER");
    if(bean!=null){
    bean.setRendered(Boolean.TRUE);}
    Thanks,
    Malar

  • How to recover the deleted job in sql server 2005

    Hi
    one of the user accidently deleted the job.and i want to recover the job.i have msdb backup,can i restore the database backup?
    please advice the prosess for recovering the deleted job
    koteswarrao

    You can but be careful.
    Restore the database as MSDB_Restored and then query sysjobs, sysjobsteps and sysjobschedules to get the details of your job and then use the detail to recreate the Job.
    Tony C

  • Issue converting the following query to text.

    Hello guys, I'm trying to convert the following query to text and to use PRINT so that it returns theresult in the picture as output, help would be appreciated, thanks :)SELECT EventName, EventDate
    FROM EventTable
    ORDER BY EventDate DESC;

    This is an example, As I said it is not a good approach
    set nocount on
    declare @tab table(id int,txt varchar(100));
    declare @txt varchar(1000);
    declare @count int;
    insert into @tab
    values(1,'Text 1'),(2,'Text 2'),(4,'Text 4');
    select *,RN=ROW_NUMBER()OVER(ORDER BY (SELECT NULL)) into #temp from @tab
    select @count=@@ROWCOUNT;
    while @count>0
    begin
    select @txt =right(replicate(' ',50)+convert(varchar(50),ID),50) +
    right(replicate(' ',50)+convert(varchar(50),txt),50)
    from #temp where RN=@count
    set @count=@count-1
    print @txt
    end
    drop Table #temp
    Satheesh
    My Blog |
    How to ask questions in technical forum

  • How to convert rows to columns in sql server 2008

    How to convert rows to columns in sql server 2008 using the GROUP BY function? (only one query allowed)

    Lookup the Pivot transformation. From BOL:
    The Pivot transformation makes a normalized data set into a less normalized
    but more compact version by pivoting the input data on a column value. For
    example, a normalized Orders data set that lists customer name, product, and quantity purchased typically has multiple rows for any customer who purchased multiple products, with each row for that customer showing order
    details for a different product. By pivoting the data set on the product column, the Pivot transformation can output a data set with a
    single row per customer. That single row lists all the purchases by the customer, with the product names shown as column names, and the quantity shown as a value in the product column. Because not every customer purchases every product, many columns may contain
    null values.
    When a dataset is pivoted, input columns perform different roles in the pivoting process. A column can participate in the following ways:
    The column is passed through unchanged to the output. Because many input rows
    can result only in one output row, the transformation copies only the first
    input value for the column.
    The column acts as the key or part of the key that identifies a set of
    records.
    The column defines the pivot. The values in this column are associated with
    columns in the pivoted dataset.
    The column contains values that are placed in the columns that the pivot
    creates.
    Paul

  • How to access the MDX application from SQL server when working with OBIEE?

    Hi,
    I am new to MS SQL Server 2005. We have developed the OLAP Cubes on SQL Server Business Intelligence Development Studio with its integration with Oracle Business Intelligence Enterprise Edition (OBIEE).
    The backend query is in MDX language. Now if I need to run that query I need to access the MDX Application, rite?
    So need to know how to connect to MDX application.
    Regards,

    Administration Tool: File - Import - "from multidimensional". There you choose "Provider Type" = "Analysis Server 2005". You specify the URL, user name and password. Then you can import MSAS cubes just like Essbase ones.
    Cheers

  • How to access the MDX application from SQL server?

    Hi,
    I am new to MS SQL Server 2005. We have developed the OLAP Cubes on SQL Server Business Intelligence Development Studio with its integration with Oracle Business Intelligence Enterprise Edition (OBIEE).
    The backend query is in MDX language. Now if I need to run that query I need to access the MDX Application, rite?
    So need to know how to connect to MDX application.
    Regards,

    I think that you have posted this query to the wrong forum. Try this one:
    Business Intelligence Suite Enterprise Edition
    --Andy                                                                                                                                                                                                                                                                                           

  • How do I install the jdbc driver for sql server 2005, in sql developer 4.0 ?

    Hallo together
    I need access to tables in a MS SQL Server 2005 database.
    One possibility is the JDBC driver.
    How do i install this driver ?
    Thank you very much for your postings.

    Hi,
      This is from the documentation -
    Database: Third Party JDBC Drivers
    The Third Party JDBC Drivers pane specifies drivers to be used for connections to third-party (non-Oracle) databases, such as IBM DB2, MySQL, Microsoft SQL Server, or Sybase Adaptive Server. (You do not need to add a driver for connections to Microsoft Access databases.) To add a driver, click Add Entry and select the path for the driver:
    For Microsoft SQL Server or Sybase Adaptive Server: jtds-1.2.jar, which is included in the jtds-1.2-dist.zip download
    To find a specific third-party JDBC driver, see the appropriate website (for example, http://www.mysql.com for the MySQL Connector/J JDBC driver for MySQL, http://jtds.sourceforge.net/ for the jTDS driver for Microsoft SQL Server and Sybase Adaptive Server, or search at http://www.teradata.com/ for the JDBC driver for Teradata). For MySQL, use the MySQL 5.0 driver, not 5.1 or later, with SQL Developer release 1.5.
    You must specify a third-party JDBC driver or install a driver using the Check for Updates feature before you can create a database connection to a third-party database of that associated type. (See the tabs for creating connections to third-party databases in the Create/Edit/Select Database Connection dialog box.)
    Alternative:
    As an alternative to using this preference, you can click Help, then Check for Updates to install the JTDS JDBC Driver for Microsoft SQL Server and the MySQL JDBE Driver as extensions.
    Regards,
    Mike

  • Sender JDBC support the stored procedure in SQL Server 2005

    Dear All,
    My question here is , Sender is JDBC adpter support to call the Stored procedure in Microsoft SQL Server 2005?
    I followed the below thread before posting this question
    Sender JDBC Adapter Supports Stored Procedures????
    In the thread Suraj response has mentioned SAP note: 941317, I checked the note, Note says it supported only ORACLE DBMS versions.
    Could you please clarify about this to possibility to call the stored procedure in Microsoft SQL server 2005?
    Thank you in Advance
    Sateesh

    Hi Sateesh,
    To answer your query, Yes it does. SP call works with SQL Server 2005 as well, the SP call should be "execute SPNAME <paramas>". In the place of update statement put any junk value as mentioned in the earlier comment.
    But just one thing to be noted, the select or any other query returning the desired resultset must be the first statement in youre SP returning value to the calling app. Means if there are any update, deletion or intermediate select queries to be used with in your SP, those all should be placed after the Main Select query that returns the desired resultset. Variable declarions and assignments are allowed.
    But if the seq of statements in your SP are like:
    @var1 Varchar
    Update <tablename>....
    Select * from <tablename>
    Then the output of the SP is :
    1 row updated
    <the resultset from select>
    In such cases, PI can recognise the first value returned only, that is "1 row updated" and hence the returned resultset wouldn't be seen by PI or not be passed to integration engine. Hence the update should come after the main Select.
    One more interesting piece of information, even if you copy and paste the entire SP code in place of the query string of Sender JDBC adapter, that too will work with all your variable declarations, multiple queries and updates and everything. Just have to follow the above rule.
    Let us know what you find.
    Regards,
    Suddhasatta

  • How much Memory should be allocated to SQL Server 2005

    Hi,
    I have a SQL Server 2005 installation on a server having 64GBof RAM.
    SQL server is allocated 57GB of the available RAM.
    Could you please tell me what would be the ideal RAM allocation for my scenario. is the one that is set now, fine.
    How much RAM should be left for the OS and other processes to run?
    I have around 8 databases on the server and the cumulative size of all the databases in about 800GB, these are highly used servers, used for a public domain.

    Umesh,
    Saeid and Uri has already given you good articles to refer to please read them. Reg SQL Server utilization I am sure you are referring to task manager which is always not correct place to look for memory utilization. Below link has query which will give
    you SQL Server memory utilization
    http://blogs.msdn.com/b/sqlsakthi/archive/2011/02/28/t-sql-script-to-monitor-memory-usage-by-sql-server-instance.aspx
    Article provided by Uri will give you not absolute value but almost correct value, but since you asked absolute value you need to look at performance counter to reach at correct memory utilization. If you refer to section 'Does my SQL server has low memory'
    in article which Saeid gave you will find list of counters to monitor for memory utilization use the counters to reah absolute value.
    >>OK, Can high RAM utilization by sql server cause the OS to restart by any chance.
    IMO its not possible I have never seen SQL server being cause for OS shutdown. SQL Server works in non preemptive mode and will yield memory to OS when required. One possibility is when SQL server has locked pages in memory(LPIM)  and some rouge process
    or driver starts using memory from OS heavily and since  SQL server memory is locked( due to LPIM privilege)  it cannot trim heavily resulting in OS to terminate but this is not because of SQL server but because of bad drivers and processes leaking
    memory on OS.
    SQL server using memory is normal behavior
    >>This question seems vague, but I had to ask this, because my server restarts abruptly and I don't get valid reasons in the Logs for that matter.
    Does SQL server starts abruptly or windows OS ? Please look at event viewer for more details and SQL server logs. Is your SQL Server 2005 patched to SP4
    Please mark this reply as answer if it solved your issue or vote as helpful if it helped so that other forum members can benefit from it.
    My TechNet Wiki Articles

  • How to do a silent configuration of SQL Server 2005 to a static tcp port ?

    Hello,
    I have a SQL server 2005 but after checking the ports of sql server,it is observed that dynamic ports are being used.
    I want to install SQL server 2005 and configure SQL serevr to a static TCP port by using silent mode of installation.There are ways to do it using SQL configuration manager and using server network utility but I want it through the silent mode.
    Please help to assist how this can be achieved through silent mode of installation.

    Hi AshishB,
    According to your description, you want to configure SQL Server to a static TCP port by using silent mode of installation. I recommend you use WMI scripting and the SQL Server WMI provider. After installation, change the TCP/IP port with the script. For
    more information about silent installing with fixed TCP port, you can review the following article.
    http://social.msdn.microsoft.com/Forums/sqlserver/en-US/914f8b72-3164-47ae-91fb-f7ed6f8ea7e6/silent-install-with-fixed-tcp-port?forum=sqlexpress
    There is detail about how to configure that manual by launching the SQL Server configuration manager, enabling TCP/IP connections, specifying the ports from the command line, you can review the following post.
    http://stackoverflow.com/questions/9138172/enable-tcp-ip-remote-connections-to-sql-server-express-already-installed-databas
    Regards,
    Sofiya Li
    Sofiya Li
    TechNet Community Support

  • How can I login to my MS SQL Server 2005 if I forgot my login password

    Hi,
    I am using SQL Server 2005 at home.
    My problem is I forgot my password to log in to my server.
    I only remember user name is 'sa'.
    I haven't used it for two to three months. So I forgot password.
    Previously, When I used sql server 2000, my login is as windows login. so no problem.
    But this time, I set seperate log in and I got this problem.
    Any help will be appreciated.
    Thanks
    George

     I hope the following article will help: http://blogs.msdn.com/raulga/archive/2007/07/12/disaster-recovery-what-to-do-when-the-sa-account-password-is-lost-in-sql-server-2005.aspx
      Please let us know if you have any further problems or questions.
      Thanks,
      -Raul Garcia
      SDE/T
      SQL Server Engine
     

  • Is there a way to convert Crystal Reports to Microsoft SQL Server 2005 reporting services?

    Post Author: Lourdes Hernandez
    CA Forum: General
    Our department has always worked with and we love Crystal Reports. Unfortunately, certain reports now need to be converted to Microsoft SQL Server 2005 reporting services which from what I read I think they are *.rdl reports. Does Crystal reports have any way around this? I would have to learn this other tool when I'm already so happy with Crystal. I was thinking If I could just code the report in crystal and export it in a specific format that would be compatible Microsoft, the problem would be solved.
    Any ideas would be greatly appreciated.

    Post Author: bettername
    CA Forum: General
    Ditto!
    There are some software packages to convert from CR to RS, but none work 100% AFAIK, and will require manual tuning.
    Seems like a big hassle and learning curve just to get reports published via another method - I know I'd put up huge resistance if they tried to take my CR away from me!

  • SQL Server Error when tryingt to install the CMS DB on SQL Server 2005 x64

    I am trying to install BOEXI R3 on w2k3 64-bit OS in a SQL Server 2005 x64 database, I am currently at the installation step where i Specify an exisiting CMS database. I created a System DSN and tested it, and it was successful. So when I got to the screen where I select my datasource I had to check use trusted connection because the datasource would not show up when Use DSN created by WOW64 option was checked. From there I could select the database I created. Oh yeah, I also made the application server local system account part of my DB admins group so it has full access to the database yet when I click next to connect I get a CMS Database Error: STU000226. here is what I have in my log:
    ThreadID     Message
    (Thu Apr 23 20:57:46 2009)     3024     3028     trace message: findDFA_LLR:  (CmdLineDir) C:Documents and SettingsgsdadminDesktopBOEXI and BSM AnalyticsBOEXI R3 Full Version from SAPpackagedbcheck
    sqlrule.llr
    (Thu Apr 23 20:57:46 2009)     3024     3028     trace message: Loading: database subsystem only
    (Thu Apr 23 20:57:46 2009)     3024     3028     trace message: loading libary succeeded
    (Thu Apr 23 20:57:46 2009)     3024     3028     trace message: DatabaseSubsystem::Init()
    (Thu Apr 23 20:57:46 2009)     3024     3028     (.wireobinit.cpp:96): trace message: Creating the shared CWireObject::PropertyNameMap
    (Thu Apr 23 20:57:46 2009)     3024     3028     (.wireobinit.cpp:118): trace message: Setting static property map
    (Thu Apr 23 20:57:46 2009)     3024     3028     (.wireobinit.cpp:125): trace message: CWireObject::InitializeStaticPropertyMap() - reference count: 1
    (Thu Apr 23 20:57:46 2009)     3024     3028     trace message: initializing subsystem succeeded
    (Thu Apr 23 20:57:46 2009)     3024     3028     trace message: Loading: done loading subsystem - database subsystem only
    (Thu Apr 23 20:57:46 2009)     3024     3028     trace message: DatabaseSubsystem::Connect()
    (Thu Apr 23 20:57:46 2009)     3024     3028     (.DBConnectionManager.cpp:802): trace message: DBConnectionManager - Setting total target number of connections for pool 0 to 1.
    (Thu Apr 23 20:57:46 2009)     3024     3028     (.SQLServerDatabase.cpp:119): trace message: SQLServer error found:  ErrorMessage( (Microsoft)[ODBC Driver Manager] Data source name not found and no default driver specified), ErrorCode(0)
    (Thu Apr 23 20:57:46 2009)     3024     3028     (.dbutils.cpp:820): trace message: Caught DatabaseSubystem Error: BusinessObjects Enterprise CMS: Unable to connect to the CMS system database "BOEXI_CMS". Reason:  (Microsoft)[ODBC Driver Manager] Data source name not found and no default driver specified
    (Thu Apr 23 20:57:46 2009)     3024     3028     trace message: DatabaseSubsystem::Shutdown()
    (Thu Apr 23 20:57:46 2009)     3024     3028     (.wireobinit.cpp:175): trace message: CWireObject::TerminateStaticPropertyMap() - reference count: 1
    (Thu Apr 23 20:57:46 2009)     3024     3028     (.wireobinit.cpp:182): trace message: Releasing
    static property map
    How do I get past this?

    The workaround was, I installed the SQL Server Client tools and created a System DataSource  and then had to create a user DataSource  (it is a quirk in the installer I guess) to get past this point in the installation. Now I have an even bigger problem. Everything but the CMS installed and the installer hung at the "Configuring the CMS" part. The installation finished but when I tried to log into the Central managment console I got this error:
    Error: Server GSD-RRPT-RDC:6400 not found or server may be down (FWM 01003) null
    I looked at the forums for the cause of this error and came to the conclusion that BOEXI does not support an installation on SQL Server 2005 when using Integrated Authentication to the SQL Server. See the engineers here disabled SQL Authentication for the SQL Server and  will not allow it.
    Is this true? Or is there a workaround to install the CMS using Integrated Authentication in the DataSource ?
    Thanks.

Maybe you are looking for

  • Strange display resolution on 30" connected to Quad

    My son has just connected a 30" display to his Quad with Nvidia GE Force 6600 card and the Apple System Profiler shows resolution of 1280x800. Of course this is bad and text is BIG etc etc. The resolution for the 30" is 2560x1600. Let me backtrack a

  • Number of rows in Excel sheet

    In ABAP reports, is there any logic to find number of rows in Excel sheet. Regards, Naseer.

  • ZCC http/s-access is down

    Hi! SLES 11 SP1, ZCM 10.3.3. Not sure it is connected with upgrading SLES 11 to SP1 (see thread http://forums.novell.com/novell/nove...11-sp1-ok.html), but this is first time using ZCM I see that web access to ZCC is down for so long. With SLES 11 SP

  • Error in smsy in standalone server

    Hello all! I have installed  in the same sever, solution manager 7.01 stack 25 and SAP ECC 6 NW 7.1 EHP4. I'm trying to install in our demo system the EHP5 and with the manual i have to do via Mopz. I have configured the SLD in SAP ECC to comunicate

  • I can not hear the voice from a cloned dataSource

    MediaLocator audioFile = new MediaLocator("rtp://192.168.2.210:"+audioPort+"/audio");                          DataSource ds = Manager.createDataSource(audioFile);                          Processor processor = Manager.createRealizedProcessor(new Pro