Trying efficient sql

I have a table with 3 columns
f1 c1 val
1 3 E
1 3 W
1 3 E
3 4 E
4 5 W
I am trying to write a query like find DISTINCT values of "val" field for "f1" and "C1" fields. If it returns both "E" and "W"
just display "BOTH" or if it "E" write EVENT or it it is "W" just display "WORD"
For Example, for 1 and 3 values ---> BOTH
3 and 4 values ---> EVENT
4 and 5 values ----> WORD
You help is appreciated:

drop table t purge
create table t
f1 number,
c1 number,
val char(1)
insert into t values (1,3,'E');
insert into t values (1,3,'W');
insert into t values (1,3,'E');
insert into t values (3,4,'E');
insert into t values (4,5,'W');
commit;
select *
from t;
F1 C1 VAL
1 3 E
1 3 W
1 3 E
3 4 E
4 5 W
5 rows selected
select f1,c1,
decode(cnte,0,decode(cntw,0,'None','Word'),decode(cntw,0,'EVENT','BOTH'))dcd
from
(select f1,c1,count(decode(val,'E','E'))cnte,
count(decode(val,'W','W'))cntw
from t
group by f1,c1);
F1 C1 DCD
4 5 Word
1 3 BOTH
3 4 EVENT
3 rows selected

Similar Messages

  • Efficient SQL Query

    Hi,
    I need to write an efficient query because the query involves 4 checks to be performed on rows before returning a single row. Here is a sample query script for creating the table:
    CREATE TABLE "myschema"."Complaint"
         "Compalint_ID" NUMBER(20,0),
         "ReplyTime" NUMBER, -- this would be in minutes
         "CREATION_TIME" TIMESTAMP (6),
    "STATUS" NUMBER,
         "TYPE" NUMBER,
         CONSTRAINT "CH_PKRTBL_Complaint_ID" PRIMARY KEY ("Compalint_ID")
    USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS
    STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
    PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
    TABLESPACE "myspace" ENABLE
    ) PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING
    STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
    PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
    TABLESPACE "myspace" ;
    CREATE UNIQUE INDEX "myschema"."CH_PKRTBL_Complaint_ID" ON "myschema"."Complaint" ("Compalint_ID")
    PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS
    STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
    PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
    TABLESPACE "myspace" ;
    ALTER TABLE "myschema"."Complaint" ADD CONSTRAINT "CH_PKRTBL_TKTID" PRIMARY KEY ("Compalint_ID")
    USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS
    STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
    PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
    TABLESPACE "myspace" ENABLE;
    I want to write an efficient sql/pl-sql query with least time to return a row based on following four checks/priorities in order spcified below:
    1. Retun any row which has TYPE = 11
    2. If no row found for 1st check then
         calculate a time difference for all rows as: time_difference (CREATION_TIME - ReplyTime)
         and return the row which has largest differene in -ve (that is the row which has expired first)
    3. If now row found for check 2 then
         return row where SATUS = 22
    4. If no row found for check 3 then
         calculate a time difference for all rows as: time_difference (CREATION_TIME - ReplyTime)
         and return the row which has smallest differene in +ve (that is the row which is going to expire next)
    Kindly help me in achieving this task.
    Thanks.

    Just an idea (not sure about the definitions first expired and next to expire )
    select complaint_id,reply_time,creation_time,complaint_status,complaint_type,
      from (select complaint_id,reply_time,creation_time,complaint_status,complaint_type,
                   case complaint_type when 11 then 11 end check1,
                   systimestamp - (creation_time + reply_time / 60/24) check2,
                   case complaint_type when 22 then 22 end check3,
                   systimestamp - (creation_time + reply_time / 60/24) check4,
                   max(case complaint_type when 11 then 11 end) over
                      (order by null rows between unbounded preceding and unbounded following) check1_max,
                   min(case when systimestamp - (creation_time + reply_time / 60/24) < 0
                            then systimestamp - (creation_time + reply_time / 60/24)
                       end
                      ) over
                      (order by null rows between unbounded preceding and unbounded following) check2_max,
                   max(case complaint_type when 22 then 22 end) over
                      (order by null rows between unbounded preceding and unbounded following) check3_max,
                   min(case when systimestamp - (creation_time + reply_time / 60/24) > 0
                            then systimestamp - (creation_time + reply_time / 60/24)
                       end
                      ) over
                      (order by null rows between unbounded preceding and unbounded following) check4_min
              from complaint
    where coalesce(check1,check2,check3,check4) = coalesce(check1_max,check2_max,check3_max,check4_min)Regards
    Etbin

  • Could  you please tell me how to write efficient SQL queries?

    Hi
    Could you please tell me how to tune or write an efficient SQL query?
    Regards,

    Hi user576726
    Pls study & try this ....
    When your query takes too long ...
    hope it helps....
    Regards,
    Abdetu...

  • What is a efficient SQL for this query ?

    Hi,
    I am using 9.2 database. Suppose I am having following 2 tables
    Table p having only one column i.e. 'a'. Values in this column are
    a1
    b1
    c1
    d1
    Table Q having three columns a, b, c
    a1, 1, 100
    a1, 2, 50
    b1, 1, 30
    b1, 2, 40
    d1, 2, 90
    Table Q can be joined only using column a.
    Table Q can have multiple or no records for column a in table p. Based on above sample data, I want following output
    a1, 100, 50
    b1, 30, 40
    c1
    d1, 90
    Kindly tell be how can I achive this in most efiicient way !!!
    thanks & regards
    PJP

    I only have you two tracks about how do it.
    If you want all the columns from p with or wihout q you have to do:
    11:35:58 SQL> l
    1 select p.*, q.*
    2 from p,q
    3* where p.a = q.a (+)
    11:37:27 SQL> /
    For change the order of the colums for rows you can see the url, the are more examples like that only need to search "columns for rows" in this forums.
    Anyway:
    with rt as
    select 'a1' a, 1 b, 100 c from dual union
    select 'a1', 2, 50 from dual union
    select 'b1', 1, 30 from dual union
    select 'b1', 2, 40 from dual union
    select 'd1', 2, 90 from dual)
    --select * from rt
    select a, decode('1','0','0',rtrim(xmlagg(xmlelement(b, b || ',')).extract('//text()'),',')) b
    , decode('1','0','0',rtrim(xmlagg(xmlelement(c, c || ',')).extract('//text()'),','))
    from rt
    group by a
    Message was edited by:
    cth
    Other way:
    select a, ltrim(b,',') as b, ltrim(c,',') as c
    from (
    select row_number() over (partition by a order by length(b) desc) as rn, a, b,c
    from (select a, sys_connect_by_path(b, ',') as b,
              sys_connect_by_path(c, ',') as c
    from (
    select row_number() over (partition by a order by b) as rn, a, b,c
    from rt) y
    connect by rn = prior rn + 1 and prior a = a
    start with rn = 1
    where rn = 1
    Message was edited by:
    cth

  • Please sugges the link helpful for writing efficient sql queries

    Please suggest any good resource that is weblink which can help me in optimizing sql queries. especially while writing select statements improve the execution time of the sql query.
    Thanx in advance
    prasanth

    in general I found books from O'Reilly very helpful (not only for Oracle, but for Unix too).
    Moreover there is pretty good Oracle Documentation available.
    After all, it's not only about writing good queries, but also about setting up data-models, indexes, primary keys, etc.
    Look for a real slow computer, take a lot of data, then try writing your speedy queries. This is the school of hard knocks, on the long run it's the best training.

  • Need efficient SQL query to retrieve data for MLM website

    Table cd_members
    MemberID LeftID RightID
    1 2 3
    2 4 5
    3 6 7
    4 8 -
    5 - -
    6 - -
    7 - -
    8 9 10
    9 - -
    10 - -
    i want to execute a query to retrieve downline of a member say MemberID 2
    o/p should be Records with MemberID 4,5,8,9,10
    i am using this query but don't know how to start from MembeID=2
    select a.memberid, a.tradingid, a.refid, a.parentid, a.node, a.leftid, a.rightid, b.memberid from cd_members a, cd_members b
    where (a.leftid=b.memberid or a.rightid=b.memberid)

    Again, assuming that the number of levels is known, you can just do N self joins (note that I intentionally go one level further than necessary in this case
    SQL> ed
    Wrote file afiedt.buf
      1  with t
      2    as
      3   (
      4      select 1 person, 2 left, 3 right from dual union all
      5      select 2, 4, 5 from dual union all
      6      select 3, 6, 7 from dual union all
      7      select 4, 8, null from dual union all
      8      select 5, null, null from dual union all
      9      select 6, null, null from dual union all
    10      select 7, null, null from dual union all
    11      select 8, 9, 10 from dual union all
    12      select 9, null, null from dual union all
    13      select 10, null, null from dual
    14   )
    15   select t1.left, t1.right, t2.left, t2.right, t3.left, t3.right, t4.left, t
    4.right
    16     from t t1,
    17          t t2,
    18          t t3,
    19          t t4
    20    where t1.person = 2
    21      and t1.left = t2.person(+)
    22      and t2.left = t3.person(+)
    23*     and t3.left = t4.person(+)
    SQL> /
          LEFT      RIGHT       LEFT      RIGHT       LEFT      RIGHT       LEFT
         RIGHT
             4          5          8                     9         10Justin

  • To use SQL or to not use SQL ..... That is the question

    A couple of posts lately have brought something to my attention that I wanted to discuss between the folks that view this forum because I believe it is important. I highly value the opinions of many of the members here so I think getting your insight would not only benefit me, but many other forum members as well.
    This discussion stems from two posts:
    {message:id=3786432} (Billy)
    ...The question that you need to ask yourself is why use such a technique? For rendering the data a specific way in the client? Well, rendering data is NOT a SQL function and in essence a result of ignorance of how to correctly use client-server. Rendering on the client is dealt with by the client itself. Using SQL to do it.. not only nasty (as many of these examples above are), but also far from optimal and efficient SQL. And in most cases, will not scale. Increase the data volume of the table queried and there will be a hefty performance knock as SQL is incorrectly used.
    ...>
    {message:id=3914362} (Sven W.)
    ...For the Pivot considerations. It is usually much better not to try to do this inside the database. If you think about it. The data itself can be fetch from the database very easily. To do a PIVOT is a kind of GUI/Layout representation for this data. This should be done in the GUI Layer.
    >
    I tried to respond to the thread Billy posted in, so I'll cut and paste my response here:
    Discussion
    Where do we as database developers draw the line between the correct use of SQL or not? Or between rendering on the client and just returning data?
    Now with LISTAGG, PIVOT and UNPIVOT all available to us would these be considered correct uses of SQL?
    Where does this leave the TO_CHAR function? Is this considered rendering?
    I'm fully expecting a fuzzy answer with something along the lines of "do the work where it makes the most sense" from a ease of development and maintainability perspective but I just wanted to ask.
    Hopefully this is a valuable discussion.
    Thanks!

    Let me give a simple example. You can store images in a table as a LOB. You can serve these images to a web browser client via mod_plsql.
    However, the data is static. It requires I/O (and some hefty ones for larger images). What is the biggest performance penalty we have in Oracle? I/O? What is affected by doing I/O to read these images? The buffer cache (which will age out other data in the cache).
    Where else can we store this data? The web server. At what cost to the performance of Oracle? None. Impact on web server? Heck, web servers are designed at their very core to do this!
    So where is the best place to storage static images in this specific case? Not the database, but the web server.
    Now simply extend this concept to the client - where is the best place to render data?
    Should the data be formatted for rendering (e.g. converted into HTML) in the database layer, or should it rather be done in the presentation layer?
    Now I can already hear the argument that the former is exactly what we are doing using APEX. We create dynamic HTML pages on the Oracle server side and then dish that up to the rendering layer to display.
    Two issues that need to be considered. Firstly, this is not done using SQL. This is done using a procedure language called PL/SQL - not using native SQL. PL/SQL in this case is used exactly as Java or PHP or Perl or any other "+app layer+" language would be used. It only happens that PL/SQL resides in the database too. But do not mistake it for what it really is - the application layer.
    The second issue drives home the point that even in 3 tier client server, the application layer is not the best place to do the formatting for the rendering layer. Web 2.0 aka AJAX.. Where the app layer delivers a dynamic rendering engine (as Javascript) to the rendering layer. After which rendering and formatting are done solely inside that rendering layer. And interaction between that and the app layer is requests for new/fresh data to be rendered.
    Why is AJAX becoming so popular? Key issues and concepts like performance, and a rich client interface and so on.
    This all points that the fundamental principle of using the rendering layer to do its thing and using the SQL layer to do its (separate and different) thing, still holds true.
    Yes, we may not always stick to this principle - as we do with doing the rendering (creating HTML) in PL/SQL using APEX for example.. but this is not because the principle is unsound. It is because of technology reasons (different browsers, different behaviour), lack of support for W3C standards (hello IE) and so on.
    It is only recently that these problem areas have been meaningfully addressed.. and why rendering frameworks like extJS is the (rendering layer) future of 3 tier client server.
    If the concept of using SQL to perform rendering and formatting had any substance.. then there would have been a lot of resistance to AJAX for example. The reverse is true.. as we all want to use SQL to do SQL and want the rendering layer to do its thing without us having to code in SQL to specifically support rendering and formatting. It is clunky. It slows down the SQL (every formatting function is a tiny overhead that adds up). It does not bode well for maintenance and changes to the presentation layer. And all those tiny overheads can spell doom for scalability.
    I do not see any gray lines here, or a question of "+opinion+", or "+it depends+". The architecture is clear. The fundamentals are sound.
    The real issue is how we choose to apply these. But (the "+incorrect+") application (of these fundamentals) does not invalidate the fundamentals.

  • Creating an Hour field in an SQL Query CUIC v10.0

    I am trying to create a report that shows the calls offered etc by Hour, instead of by half hour or 15 minutes which comes with the usual DateTime (interval) query.
    I am using DATEPART (Hour, DateTime) As Hour  and whilst this is giving me the hour number in the new column, I an showing 2 rows per hour as per the half hour interval.
    I have included it in the Group By and this makes no difference, Whilst I can group them by hour and that would in effect solve the issue, I then loos the Date Field!
    Ideally what I would like to see in 1 column is
    Call Type 1    4/2/15 10:00 AM
                          4/2/15 11:00 AM
                          4/2/25 12:00 AM
    etc.....
    Instead what I have is
    Call Type 1    4/2/15 10:00 AM         10
                          4/2/15 10:30 AM         10
                          4/2/25 11:00 AM         11
                          4/2/25 11:30AM          11
    etc...
    If there is anyone out there that can help I would be most grateful
    Thanks Sarah

    Sarah,
    You will need to make sure you remove "DateTime" from your GROUP BY clause, and from the SELECT statement.
    Instead of using DATEPART, I would use something like:
    DateTimeHour = DATEADD(h,DATEDIFF(h,0,DateTime),0)
    The above will give you a full DateTime value, rounded down to the nearest hour. Don't forget to include it in the GROUP BY (and probably SORT BY).
    You can add "DateTime" back as Filter Field in CUIC after you do the initial Create Fields step (look on the Fields page). Filtering on DateTime instead of DATEADD(h,DATEDIFF(h,0,DateTime),0) should make for a more efficient SQL query.
    -Jameson

  • How to export MySql queryBrowser to oracle's .sql file

    Hi folks:
    I was trying to export result set from MySql query browser to Oracle. I could able to do
    File->Export Result Set-> Excel format...
    What I am trying to get is .sql file so that I can run it as a script in my oracle db. Is there any way we can get .sql file with inserts and delimeters ....?
    Did you guys get my question.?
    Please throw some light on this....
    Could be very appreciable ....
    Thanks
    Sudhir Naidu

    As already pointed out the implementation is bad.
    You should have:
    USERS ( ID )
    GROUPS ( ID )
    USER_GROUPS( USER_ID,GROUP_ID )The reason for not using the CSV list is that not only is it hard to write efficient SQL against denormalised structures, but it is very difficult to constrain your data properly.
    But anyhow, Oracle 10g has a MEMBER OF function. Too bad you're on 9i. You say "new task", is the platform still up for decision?
    You could normalise on the fly like this
    e.g.
    SELECT t.GROUP_ID
          ,EXTRACTVALUE (csv_to_tab.COLUMN_VALUE, 'user')
           user_id
      FROM t_user t
          ,TABLE (XMLSEQUENCE (EXTRACT (XMLTYPE
    (   '<set><user>'|| REPLACE
    (t.users,',','</user><user>' )                       
    || '</user></set>'), '/set/*'))) csv_to_tab

  • Browse Data & Parameter flds no longer fully populated after upgd  SQL 2005

    I upgrade our SQL 2000 Server last weekend to SQL 2005 (sp2).
    Now our Crystal reports that access SQL data are not working correctly. Parameter Fields are showing little to no data, where before the upgrade we were seeing many more rows in the list.
    Digging further, I looked at the fields used for the dynamic LOV. If I use Browse Data on those fields I am seeing the same lack of data. One "Browse Data" that would typically return 80 items now returns 3 items. In that report the data field is DateTime. In another report, the field is string.
    I am also seeing an extra check for User Name and password before getting to the Enter values screen for the parameter.
    I am using Crystal Developer 11.0.0.1994. It is happening on multiple PCs. I tried with both the original SQL ODBC Driver and the newer SQL Native Client ODBC driver, with the same result.
    I've looked at this for 3 days with no luck. Any ideas?

    Full SysAdmin rights.
    I use a dedicated ODBC connection and have tried both "SQL Server" odbc driver and "SQL NativeClient" (2005) odbc driver.
    If I go to Crystal, to the Field Explorer, to the one of the fields, right-click and "Browse Data..." I get two results (I expect 82 results and have seen that in the past.) If I paste the query from Crystal, Database, "Show SQL Query.."  to SQL Server Management Studio, I see the full, correct results.
    In one example the field browsed is called "PeriodEndDate" (DateTime). A dynamic Parameter Field was created accessing this field. Here is the security curiosity...refreshing now asks for the user login each time "Prompt for new parameter values" is selected. It used to ask only the first time. The Crystal: Data Explorer" shows the current connection logged in ok.
    The two issues may or may not be related. Certainly if #1 were fixed, dynamic parameters would return the correct results. Even if it asked for the password each time.
    1.) "Browse Data" returning a smaller result than normal.
    2.) "Parameter Prompt" asks for Server Name, Database Name, User Name, and Password on
         each refresh selecting "Prompt for new parameter values".

  • Error Installing SQL Server Express 2008: '' is not a valid login or you do not have permission.

    I have tried installing SQL Server 2008 multiple times on my machine, and I always receive this error about 3/4 of the way through: '' is not a valid login or you do not have permission.
    I have tried installing both SQL Server Express 2008 with Tools and SQL Server Express 2008 with Advanced Services, and they both fail the same way. I am trying to do a new stand-alone installation.
    I'm running Windows XP Home Edition SP3.
    Looking into the error, some forums say I have to install it from THE Administrator account, and not an account with administrator permissions; it also cannot be in Safe Mode, because then the Windows Installer won't work. Unfortunately, I haven't been able to login to the Administrator account. I can go to the home login screen, do ctrl+alt+del twice, and attempt to login to the Administrator account, but I receive this error: Unable to Log You on because of an Account Restriction.
    Other forums say that in the Server Configuration section, all you have to do is provide the username and a strong password from an administrative account on the computer, and it doesn't have to be THE Administrator. Well, I did that, but for some reason it doesn't recognize my username and password, it says something like "The credentials you provided for the SQL Server Agent are invalid". BUT THOSE ARE THE CORRECT CREDENTIALS FOR MY ADMINISTRATIVE USER! So I'm forced to use one of the accounts without a password, like NT AUTHORITY\SYSTEM. That's the only way I can get past this step.
    Also, just FYI, on the next step, which is Database Engine Configuration, I am using Mixed Mode for the Security Mode. I AGAIN provide a password, and then add my current user (who IS an administrator on my machine!) to the SQL Server Administrators box.
    But yet, it fails every single time.
    This is pathetic and ridiculous. I must have tried to install this thing 15 times, that is not an exaggeration. I'm posting this on several other forums as well, maybe an MVP or Bill Gates himself can help me.
    I have one of the log files from a failed installation. If someone would like to see it, I will post it.

     Papy Normand wrote:
    Hello,
    Please, could you have a look on the excellent answer of Mike Wachal you will find here :
    http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=4160294&SiteID=1
    Don't hesitate to post again for more help or explanations
    Have a nice day
    PS : if you are talking about the Sql Server Agent Service, it is disabled for Sql Server Express. It is enabled only for the Workgroup/Standard/Dev and Entreprise Editions
    Sorry, but I've tried the suggestion in that link, and it hasn't helped me.
    For anyone wonder, the link is talking about the problem in Server Configuration where I enter my Windows user account and password (which is in the Administrative group), but it says the credentials are invalid.  The link suggests that you need to either enter your Windows account (which I did, and it wouldn't let me go to the next step), or to use one of the built in accounts (which I also tried, but it gave me the " '' is not a valid login" error during the installation).
    Any other ideas?
    I haven't had any answers from any other forums either, so I'll just post my log file in case anyone wants to look at this:
    Overall summary:
      Final result:                  SQL Server installation failed. To continue, investigate the reason for the failure, correct the problem, uninstall SQL Server, and then rerun SQL Server Setup.
      Exit code (Decimal):           -2068643839
      Exit facility code:            1203
      Exit error code:               1
      Exit message:                  SQL Server installation failed. To continue, investigate the reason for the failure, correct the problem, uninstall SQL Server, and then rerun SQL Server Setup.
      Start time:                    2008-11-17 11:13:47
      End time:                      2008-11-17 12:17:25
      Requested action:              Install
      Log with failure:              C:\Program Files\Microsoft SQL Server\100\Setup Bootstrap\Log\20081117_110917\Detail.txt
      Exception help link:           http%3a%2f%2fgo.microsoft.com%2ffwlink%3fLinkId%3d20476%26ProdName%3dMicrosoft%2bSQL%2bServer%26EvtSrc%3dsetup.rll%26EvtID%3d50000%26ProdVer%3d10.0.1600.22%26EvtType%3d0xBE029E38%400x12C2466D
    Machine Properties:
      Machine name:                  STEVEN
      Machine processor count:       2
      OS version:                    Windows XP
      OS service pack:               Service Pack 3
      OS region:                     United States
      OS language:                   English (United States)
      OS architecture:               x86
      Process architecture:          32 Bit
      OS clustered:                  No
    Product features discovered:
      Product              Instance             Instance ID                    Feature                                  Language             Edition              Version         Clustered
    Package properties:
      Description:                   SQL Server Database Services 2008
      SQLProductFamilyCode:          {628F8F38-600E-493D-9946-F4178F20A8A9}
      ProductName:                   SQL2008
      Type:                          RTM
      Version:                       10
      SPLevel:                       0
      Installation location:         D:\x86\setup\
      Installation edition:          DEVELOPER
    User Input Settings:
      ACTION:                        Install
      ADDCURRENTUSERASSQLADMIN:      False
      AGTSVCACCOUNT:                 NT AUTHORITY\SYSTEM
      AGTSVCPASSWORD:                *****
      AGTSVCSTARTUPTYPE:             Manual
      ASBACKUPDIR:                   C:\Program Files\Microsoft SQL Server\MSAS10.MSSQLSERVER\OLAP\Backup
      ASCOLLATION:                   Latin1_General_CI_AS
      ASCONFIGDIR:                   C:\Program Files\Microsoft SQL Server\MSAS10.MSSQLSERVER\OLAP\Config
      ASDATADIR:                     C:\Program Files\Microsoft SQL Server\MSAS10.MSSQLSERVER\OLAP\Data
      ASDOMAINGROUP:                 <empty>
      ASLOGDIR:                      C:\Program Files\Microsoft SQL Server\MSAS10.MSSQLSERVER\OLAP\Log
      ASPROVIDERMSOLAP:              1
      ASSVCACCOUNT:                  NT AUTHORITY\SYSTEM
      ASSVCPASSWORD:                 *****
      ASSVCSTARTUPTYPE:              Automatic
      ASSYSADMINACCOUNTS:            STEVEN\Steven
      ASTEMPDIR:                     C:\Program Files\Microsoft SQL Server\MSAS10.MSSQLSERVER\OLAP\Temp
      BROWSERSVCSTARTUPTYPE:         Disabled
      CONFIGURATIONFILE:             C:\Program Files\Microsoft SQL Server\100\Setup Bootstrap\Log\20081117_110917\ConfigurationFile.ini
      ENABLERANU:                    False
      ERRORREPORTING:                False
      FEATURES:                      SQLENGINE,REPLICATION,FULLTEXT,AS,RS,BIDS,CONN,IS,BC,SDK,BOL,SSMS,ADV_SSMS,SNAC_SDK,OCS
      FILESTREAMLEVEL:               0
      FILESTREAMSHARENAME:           <empty>
      FTSVCACCOUNT:                  NT AUTHORITY\LOCAL SERVICE
      FTSVCPASSWORD:                 *****
      HELP:                          False
      INDICATEPROGRESS:              False
      INSTALLSHAREDDIR:              C:\Program Files\Microsoft SQL Server\
      INSTALLSHAREDWOWDIR:           C:\Program Files\Microsoft SQL Server\
      INSTALLSQLDATADIR:             <empty>
      INSTANCEDIR:                   C:\Program Files\Microsoft SQL Server\
      INSTANCEID:                    MSSQLSERVER
      INSTANCENAME:                  MSSQLSERVER
      ISSVCACCOUNT:                  NT AUTHORITY\SYSTEM
      ISSVCPASSWORD:                 *****
      ISSVCSTARTUPTYPE:              Automatic
      MEDIASOURCE:                   D:\
      NPENABLED:                     0
      PID:                           *****
      QUIET:                         False
      QUIETSIMPLE:                   False
      RSINSTALLMODE:                 DefaultNativeMode
      RSSVCACCOUNT:                  NT AUTHORITY\SYSTEM
      RSSVCPASSWORD:                 *****
      RSSVCSTARTUPTYPE:              Automatic
      SAPWD:                         *****
      SECURITYMODE:                  SQL
      SQLBACKUPDIR:                  <empty>
      SQLCOLLATION:                  SQL_Latin1_General_CP1_CI_AS
      SQLSVCACCOUNT:                 NT AUTHORITY\SYSTEM
      SQLSVCPASSWORD:                *****
      SQLSVCSTARTUPTYPE:             Automatic
      SQLSYSADMINACCOUNTS:           STEVEN\Steven
      SQLTEMPDBDIR:                  <empty>
      SQLTEMPDBLOGDIR:               <empty>
      SQLUSERDBDIR:                  <empty>
      SQLUSERDBLOGDIR:               <empty>
      SQMREPORTING:                  False
      TCPENABLED:                    0
      X86:                           False
      Configuration file:            C:\Program Files\Microsoft SQL Server\100\Setup Bootstrap\Log\20081117_110917\ConfigurationFile.ini
    Detailed results:
      Feature:                       Database Engine Services
      Status:                        Failed: see logs for details
      MSI status:                    Passed
      Configuration status:          Failed: see details below
      Configuration error code:      0x12C2466D
      Configuration error description: '' is not a valid login or you do not have permission.
      Configuration log:             C:\Program Files\Microsoft SQL Server\100\Setup Bootstrap\Log\20081117_110917\Detail.txt
      Feature:                       SQL Client Connectivity SDK
      Status:                        Passed
      MSI status:                    Passed
      Configuration status:          Passed
      Feature:                       SQL Server Replication
      Status:                        Failed: see logs for details
      MSI status:                    Passed
      Configuration status:          Failed: see details below
      Configuration error code:      0x12C2466D
      Configuration error description: '' is not a valid login or you do not have permission.
      Configuration log:             C:\Program Files\Microsoft SQL Server\100\Setup Bootstrap\Log\20081117_110917\Detail.txt
      Feature:                       Full-Text Search
      Status:                        Failed: see logs for details
      MSI status:                    Passed
      Configuration status:          Failed: see details below
      Configuration error code:      0x12C2466D
      Configuration error description: '' is not a valid login or you do not have permission.
      Configuration log:             C:\Program Files\Microsoft SQL Server\100\Setup Bootstrap\Log\20081117_110917\Detail.txt
      Feature:                       Analysis Services
      Status:                        Passed
      MSI status:                    Passed
      Configuration status:          Passed
      Feature:                       Reporting Services
      Status:                        Failed: see logs for details
      MSI status:                    Passed
      Configuration status:          Failed: see details below
      Configuration error code:      0x12C2466D
      Configuration error description: '' is not a valid login or you do not have permission.
      Configuration log:             C:\Program Files\Microsoft SQL Server\100\Setup Bootstrap\Log\20081117_110917\Detail.txt
      Feature:                       Integration Services
      Status:                        Passed
      MSI status:                    Passed
      Configuration status:          Passed
      Feature:                       Client Tools Connectivity
      Status:                        Passed
      MSI status:                    Passed
      Configuration status:          Passed
      Feature:                       Management Tools - Complete
      Status:                        Passed
      MSI status:                    Passed
      Configuration status:          Passed
      Feature:                       Management Tools - Basic
      Status:                        Passed
      MSI status:                    Passed
      Configuration status:          Passed
      Feature:                       Client Tools SDK
      Status:                        Passed
      MSI status:                    Passed
      Configuration status:          Passed
      Feature:                       Client Tools Backwards Compatibility
      Status:                        Passed
      MSI status:                    Passed
      Configuration status:          Passed
      Feature:                       Business Intelligence Development Studio
      Status:                        Passed
      MSI status:                    Passed
      Configuration status:          Passed
      Feature:                       SQL Server Books Online
      Status:                        Passed
      MSI status:                    Passed
      Configuration status:          Passed
      Feature:                       Microsoft Sync Framework
      Status:                        Passed
      MSI status:                    Passed
      Configuration status:          Passed
    Rules with failures:
    Global rules:
    Scenario specific rules:
    Rules report file:               C:\Program Files\Microsoft SQL Server\100\Setup Bootstrap\Log\20081117_110917\SystemConfigurationCheck_Report.htm

  • Possible to do variable number of REPLACE in SQL?

    Hello. Using Oracle 10G, R2
    Wondering if it is possible to do a variable number of REPLACE() entirely in SQL in a view.
    input_table.text_column = This (b)is(/b) some (i)text(/i) with (u)formatting(/u) codes
    Note: Using ( and ) to represent < and >
    rows in format_codes_table:
    (b)
    (/b)
    (i)
    (/i)
    (u)
    (/u)
    (p)
    (/p)
    etc. (The number of format_codes is not fixed)
    Desired output: This is some text with formatting codes
    This could be done with a user-defined function and then use that function in a SQL:
    create or replace function remove_format_codes(input_p IN varchar2)
    return varchar2
       v_output   varchar2(2000);
    is
    begin
       v_output := input_p;
       for r1 in (select format_code from format_codes_table)
       loop
          v_output := replace(v_output, r1.format_code);
       end loop;
       return v_output;
    end;
    create or replace view unformatted_output_vw
    as
    select remove_format_codes(input_table.text_column) as unformatted_output
    from input_table
    /I tried this SQL:
    select replace(input_table.text_column, format_codes_table.format_code) as unformatted_output
    from input_table
        ,format_codes_table
    /But it only replaces one format code at a time, and it is not recursive so the output is like this:
    This is(/b) some (i)text(/i) with (u)formatting(/u) codes
    This (b)is some (i)text(/i) with (u)formatting(/u) codes
    This (b)is(/b) some text(/i) with (u)formatting(/u) codes
    This (b)is(/b) some (i)text with (u)formatting(/u) codes
    etc.
    I've google'd Oracle recursive sql, looked at CONNECT BY, LEAD, LAG, MODEL, and I've also looked at a
    Tom Kyte example for varying in lists (http://tkyte.blogspot.com/2006/06/varying-in-lists.html),
    but I can't seem to find a way to replicate the loop in my user-defined function in SQL.
    Anyone think this is possible in SQL? If yes, any hints?
    Thanks

    Hi,
    Regular expressions (introduced in Oracle 10) are great for this:
    SELECT     REGEXP_REPLACE ( text_column
                     , '&lt;'          || -- left angle-bracket
                       '/?'          || -- optional slash
                    '[bipu]'     || -- any one of these characters
                    '>'             -- right angle-bracket
                     )      AS no_tag_text
    FROM    input_table
    ;You had some good ideas: recursive subqueries (new in Oracle 11.2), CONNECT BY and MODEL could also do this job, but not nearly as easily.
    In case you're interested, the following thread uses MODEL to do nested REPLACEs:
    SQL Query
    Edited by: Frank Kulash on May 13, 2010 4:08 PM
    Edited by: Frank Kulash on May 17, 2010 1:02 PM
    Fixed link

  • DATAEXPORT to sql server is giving error

    Hi,
    I am using DATAEXPORT to export data to SQL tables but its giving error:
    MY TABLE:
    USE SBC;
    Create table TEST
         Period nchar(20),
         HSP_Rates nchar(20),
         Years nchar(10),
         Currency nchar(5),
         Scenario nchar(20),
         ICP nchar(20),
         [Co.] nchar(20),
         Version nchar(20),
         Product nchar(20),
         Entity nchar(30),
    Account nchar(50),
         Data numeric(18, 5)
    Created this order based on export taken on file
    **My Script:**
    SET DATAEXPORTOPTIONS
         DataExportLevel "ALL";
         DATAEXPORTCOLFORMAT ON;
         DataExportOverwriteFile ON;
         DataExportDecimal 4;
    DATAEXPORTCOND ("HSP_InputValue" <> #MISSING And "HSP_InputValue" <> 0);
    FIX (@REMOVE(@RELATIVE ("Balance_Sheet",0),"CY_Earnings"),"Per7","HSP_InputValue","FY12","Local","MY12 Budget", @RELATIVE ("ICP Top",0),@RELATIVE ("Co Total",0),Working,@RELATIVE (PODS,0),@RELATIVE ("Entity",0));
    /*DATAEXPORT "File" "," "D:\Test.txt"*/
    DATAEXPORT "DSN" "TEST" "Test" "admin" "XXXXXX";
    ENDFIX;
    Output when exported to File:
    "Per7"
    "HSP_InputValue","FY12","Local","MY12 Budget","No IC","Co 100","Working","ALLEZ","100-1050","Subs_Cash",500000.046
    "HSP_InputValue","FY12","Local","MY12 Budget","No IC","Co 100","Working","AirFreight","100-1050","Subs_Cash",534324.370
    ERROR IN LOGS:
    [Fri Feb 03 01:10:20 2012]Local/SBC///15796/Info(1013210)
    User [admin@Native Directory] set active on database [SBC]
    [Fri Feb 03 01:10:20 2012]Local/SBC/SBC/admin@Native Directory/2208/Info(1013091)
    Received Command [Calculate] from user [admin@Native Directory]
    [Fri Feb 03 01:10:20 2012]Local/SBC/SBC/admin@Native Directory/2208/Info(1013167)
    Received Command [Calculate] from user [admin@Native Directory] using [Test.csc]
    [Fri Feb 03 01:10:20 2012]Local/SBC/SBC/admin@Native Directory/2208/Info(1021004)
    Connection String is generated
    [Fri Feb 03 01:10:20 2012]Local/SBC/SBC/admin@Native Directory/2208/Info(1021041)
    Connection String is [DSN=SBC;UID=...;PWD=...;]
    [Fri Feb 03 01:10:20 2012]Local/SBC/SBC/admin@Native Directory/2208/Info(1021000)
    Connection With SQL Database Server is Established
    [Fri Feb 03 01:10:20 2012]Local/SBC/SBC/admin@Native Directory/2208/Info(1021013)
    ODBC Layer Error: [21S01] ==> [[Microsoft][ODBC SQL Server Driver][SQL Server]Column name or number of supplied values does not match table definition.]
    [Fri Feb 03 01:10:20 2012]Local/SBC/SBC/admin@Native Directory/2208/Info(1021014)
    ODBC Layer Error: Native Error code [213]
    [Fri Feb 03 01:10:20 2012]Local/SBC/SBC/admin@Native Directory/2208/Error(1012085)
    Unable to export data to SQL table [Test]. Check the Essbase server log and the system console to determine the cause of the problem.
    [Fri Feb 03 01:10:20 2012]Local/SBC/SBC/admin@Native Directory/2208/Info(1021002)
    SQL Connection is Freed
    [Fri Feb 03 01:10:20 2012]Local/SBC/SBC/admin@Native Directory/2208/Warning(1080014)
    Transaction [ 0xb0006( 0x4f2b885c.0xd4e40 ) ] aborted due to status [1012085].
    [Fri Feb 03 01:10:20 2012]Local/SBC/SBC/admin@Native Directory/2208/Info(1012579)
    Total Calc Elapsed Time for [Test.csc] : [0.022] seconds
    I have tried using SQL Drivers for ODBC connection as well as Wire protocol driver.
    Please assist asap.
    Regards,
    Vinit

    Chawla,
    Fixed in 9.3.3, Check out this, their are few more bugs fixed related to DataExport.
    http://docs.oracle.com/cd/E10530_01/doc/epm.931/esb_93300_readme.pdf
    8404516 Calculator.The DATAEXPORTCOND calculation command clashes with the FIX
    command.
    8913164 Calculator. Data exports that use DATAEXPORTCOND do not always export all
    the data expected because not all conditions are taken into account within the
    DATAEXPORTCOND statement
    8988310 Calculator. When exporting data using the DATAEXPORT command from a
    duplicate outline that contains a shared hierarchy, the exported data contains the
    shared member, not the prototype Etc..
    Cheers...!!
    Rahul S.

  • Goods Issue - SQL Query will not sum

    I have 3 Goods Issue documents with Document Total for each document 10,000 / 20,000 / 30,000 subsequently.
    I want to make query so that it will display like below - where it shows BOTH each of 3 document value (10000/2000/30000) AND the sum of the 3 documents (60000) like below.
    Doc 1 - 10,000
    Doc 2 - 20,000
    Doc 3 - 30,000
    Total = 60,000
    In addition, I would like the ability to choose date range. Basically, something like
    SELECT Document_Total
    FROM Goods_Issue table
    WHERE the_document_date is between 1-SEP-2011 and 31-SEP-2011
    AND the_reference_is _________________
    I have tried many SQL queries, but it displayed either:
    Doc 1 - 10,000
    Doc 2 - 20,000
    Doc 3 - 30,000
    OR
    Total = 60,000
    Please help.

    @Hendry Wijaya      @GordonDu   @malhaar
    Thanks for helps. The SQL query you provided solved 99% of the problem. I just need to make a tweak on the SQL so that it could display the total on the footer. See screenshot below - I uploaded the pics at imageshack as I don't find a way to attach pics in here.
    [See here - Total_at_Footer|http://i129.photobucket.com/albums/p213/whitesnowbear/AAAA/Untitled-2.jpg]
    Thanks a bunch.

  • Dg4odbc, unixODBC, freeTDS - connection problems to MS SQL 2008

    I am trying to set up a database link between my 64bit Oracle 11g running on CentOS 6.2 and my MS SQL 2008 server running on MS Windows server 2003. I have installed the following -
    freeTDS - version 0.91 (64 bit)
    unixODBC - version 2.3.1 (64 bit)
    I have successfully configured ODBC and freeTDS so that I can connect using isql and query my MSSQL database. The problem I am having is connecting Oracle to MSSQL, I am sure it is a simple configuration error but I have been going round in circles with this and hope someone can help!
    freetds.conf
    [global]
    timeout = 10
    connect timeout = 10
    text size = 64512
    [CERM]
    host = 192.168.xxx.xxx
    port = 1101
    tds version = 7.2
    instance = SSLSQLDB
    dump file = /tmp/dump.log
    odbc.ini
    [ODBC Data Sources]
    CERM=TDS connection
    [CERM]
    Servername = CERM
    Description = TDS connection
    Driver = /usr/local/lib/libtdsodbc.so
    UsageCount = 1
    FileUsage = 1
    [ODBC]
    Trace=255
    odbcinst.ini
    [TDS]
    Description = FreeTDS driver for MS SQL
    Driver = /usr/local/lib/libtdsodbc.so
    Setup = /usr/lib64/libtdsS.so
    Trace = Yes
    TraceFile = /tmp/freetd.log
    FileUsage = 1
    [FreeTDS]
    Description = FreeTDS driver for MS SQL
    Driver = /usr/local/lib/libtdsodbc.so
    Setup = /usr/lib64/libtdsS.so
    Trace = Yes
    TraceFile = /tmp/freetd.log
    FileUsage = 1
    (Because I have put the actual path to the driver in the odbc.ini file I don;t believe the odbcinst.ini file is actually used)
    inithscerm.ora
    # This is a sample agent init file containing the HS parameters that
    # are needed for an ODBC Agent.
    # HS init parameters
    HS_FDS_CONNECT_INFO=CERM
    HS_FDS_TRACE_LEVEL=255
    #HS_FDS_TRACE_FILE_NAME = /tmp/hsodbcsql.trc
    HS_FDS_SHAREABLE_NAME=/usr/local/lib/libodbc.so
    HS_FDS_SUPPORT_STATISTICS=FALSE
    set ODBCINI=/usr/local/etc/odbc.ini
    (my odbc.ini file is located in /usr/local/etc)
    listener.ora
    # listener.ora Network Configuration File: /usr/oracle/product/network/admin/listener.ora
    # Generated by Oracle configuration tools.
    LISTENER =
    (DESCRIPTION_LIST =
    (DESCRIPTION =
    (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
    (ADDRESS = (PROTOCOL = TCP)(HOST = ssl-oracle.domain)(PORT = 1521))
    ADR_BASE_LISTENER = /usr/oracle
    SID_LIST_LISTENER =
    (SID_LIST =
    (SID_DESC=
    (SID_NAME=hscerm)
    (ORACLE_HOME=/usr/oracle/product)
    (PROGRAM=dg4odbc)
    (ENVS=LD_LIBRARY_PATH = /usr/local/lib:$ORACLE_HOME/lib)
    (SID_DESC=
    (SID_NAME=PROD)
    (ORACLE_HOME=/usr/oracle/product)
    tnsnames.ora
    # tnsnames.ora Network Configuration File: /usr/oracle/product/network/admin/tnsnames.ora
    # Generated by Oracle configuration tools.
    PROD =
    (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = ssl-oracle.domain)(PORT = 1521))
    (CONNECT_DATA =
    (SERVER = DEDICATED)
    (SERVICE_NAME = PROD.DOMAIN)
    hscerm=
    (DESCRIPTION=
    (ADDRESS=(PROTOCOL=TCP)(HOST=ssl-oracle.domain)(PORT=1521))
    (CONNECT_DATA= (SID=hscerm))
    (HS=OK)
    right - I can tnsping my hscerm instance and that returns ok so I'm fairly sure the configuration is fine for both tnsnames.ora and listener.ora. I can isql connect to the ODBC defined name for the the MSSQL database. but when I create a database link in Oracle and then test it I get the following trace output :-
    [ODBC][14030][1339512618.356535][SQLSetConnectAttrW.c][332]
    Entry:
    Connection = 0x2054640
    Attribute = SQL_ATTR_AUTOCOMMIT
    Value = (nil)
    StrLen = -5
    [ODBC][14030][1339512618.356616][SQLSetConnectAttrW.c][616]
    Exit:[SQL_SUCCESS]
    [ODBC][14030][1339512618.356984][SQLDriverConnectW.c][290]
    Entry:
    Connection = 0x2054640
    Window Hdl = (nil)
    Str In = [DNCR;I=APDagj20][length = 30]
    Str Out = 0x2053408
    Str Out Max = 1024
    Str Out Ptr = 0x7fff6d305770
    Completion = 0
    [ODBC][14030][1339512618.357030][SQLDriverConnectW.c][500]Error: IM002
    [ODBC][14030][1339512618.357115][SQLGetDiagRecW.c][508]
    Entry:
    Connection = 0x2054640
    Rec Number = 1
    SQLState = 0x7fff6d3053d0
    Native = 0x7fff6d3051c4
    Message Text = 0x7fff6d3051d0
    Buffer Length = 510
    Text Len Ptr = 0x7fff6d305420
    [ODBC][14030][1339512618.357153][SQLGetDiagRecW.c][550]
    Exit:[SQL_SUCCESS]
    SQLState = IM002
    Native = 0x7fff6d3051c4 -> 0
    Message Text = [[unixODBC][Driver Manager]Data source name not found, and no default driver specified]
    [ODBC][14030][1339512618.357197][SQLGetDiagRecW.c][508]
    Entry:
    Connection = 0x2054640
    Rec Number = 2
    SQLState = 0x7fff6d3053d0
    Native = 0x7fff6d3051c4
    Message Text = 0x7fff6d3051d0
    Buffer Length = 510
    Text Len Ptr = 0x7fff6d305420
    [ODBC][14030][1339512618.357228][SQLGetDiagRecW.c][550]
    Exit:[SQL_NO_DATA]
    [ODBC][14030][1339512618.357291][SQLDisconnect.c][208]
    Entry:
    Connection = 0x2054640
    [ODBC][14030][1339512618.357321][SQLDisconnect.c][237]Error: 08003
    [ODBC][14030][1339512618.357387][SQLFreeHandle.c][284]
    Entry:
    Handle Type = 2
    Input Handle = 0x2054640
    Now I can clearly see the error "Data source name not found, and no default driver specified" which according to all the documentation means that the entry HS_FDS_CONNECT_INFO=CERM does not match the entry in my odbc.ini file ([CERM]) but for the life of me I can;t see why they don;t match ??
    Any help greatly received.

    Yeah I verified with isql but I have changed the odbc.ini file as you suggested -
    [root@ssl-oracle ~]# more /usr/local/etc/odbc.ini
    [ODBC Data Sources]
    CERM=TDS connection
    [CERM]
    Server = 192.168.xxx.xxx
    Driver = /usr/local/lib/libtdsodbc.so
    Database = sqlb00
    Port = 1101
    TDS_Version = 8.0
    QuotedId = YES
    [ODBC]
    Trace=255
    [root@ssl-oracle admin]# more inithscerm.ora
    # This is a sample agent init file containing the HS parameters that
    # are needed for an ODBC Agent.
    # HS init parameters
    HS_FDS_CONNECT_INFO=CERM
    HS_FDS_TRACE_LEVEL=255
    #HS_FDS_TRACE_FILE_NAME = /tmp/hsodbcsql.trc
    HS_FDS_SHAREABLE_NAME=/usr/local/lib/libodbc.so
    HS_FDS_SUPPORT_STATISTICS=FALSE
    HS_LANGUAGE=american_america.we8mswin1252
    HS_NLS_NCHAR=UCS2
    set ODBCINI=/usr/local/etc/odbc.ini
    [root@ssl-oracle admin]# osql -S CERM -U sa -P supersecretpassword
    checking shared odbc libraries linked to isql for default directories...
    trying /tmp/sql ... no
    trying /tmp/sql ... no
    trying /usr/loc ... no
    trying /tmp/sql.log ... no
    trying /home ... no
    trying /.odbc.ini ... no
    trying /usr/local/etc ... OK
    checking odbc.ini files
    cannot read "/root/.odbc.ini"
    reading /usr/local/etc/odbc.ini
    [CERM] found in /usr/local/etc/odbc.ini
    found this section:
    [CERM]
    Server = 192.168.xxx.xxx
    Driver = /usr/local/lib/libtdsodbc.so
    Database = sqlb00
    Port = 1101
    TDS_Version = 8.0
    QuotedId = YES
    looking for driver for DSN [CERM] in /usr/local/etc/odbc.ini
    found driver line: " Driver = /usr/local/lib/libtdsodbc.so"
    driver "/usr/local/lib/libtdsodbc.so" found for [CERM] in odbc.ini
    found driver named "/usr/local/lib/libtdsodbc.so"
    /usr/local/lib/libtdsodbc.so is an executable file
    "Server" found, not using freetds.conf
    Server is "192.168.xxx.xxx"
    looking up hostname for ip address 192.168.xxx.xxx
    Configuration looks OK. Connection details:
    DSN: CERM
    odbc.ini: /usr/local/etc/odbc.ini
    Driver: /usr/local/lib/libtdsodbc.so
    Server hostname: ssl-database.domain
    Address: 192.168.xxx.xxx
    Attempting connection as sa ...
    + isql CERM sa supersecretpassword -v
    | Connected! |
    | |
    | sql-statement |
    | help [tablename] |
    | quit |
    | |
    SQL>
    sql.log
    [ODBC][31473][1339581606.488571][SQLSetConnectAttr.c][396]
    Entry:
    Connection = 0x26c2a30
    Attribute = SQL_ATTR_AUTOCOMMIT
    Value = (nil)
    StrLen = -5
    [ODBC][31473][1339581606.488638][SQLSetConnectAttr.c][681]
    Exit:[SQL_SUCCESS]
    [ODBC][31473][1339581606.488924][SQLDriverConnect.c][726]
    Entry:
    Connection = 0x26c2a30
    Window Hdl = (nil)
    Str In = [DSN=CERM;UID=SA;PWD=**********][length = 30]
    Str Out = 0x26c4b18
    Str Out Max = 1024
    Str Out Ptr = 0x7fff12846560
    Completion = 0
    UNICODE Using encoding ASCII 'ISO8859-1' and UNICODE 'UCS-2LE'
    DIAG [01000] [FreeTDS][SQL Server]Unknown host machine name.
    DIAG [08001] [FreeTDS][SQL Server]Unable to connect to data source
    [ODBC][31473][1339581606.491276][SQLDriverConnect.c][1353]
    Exit:[SQL_ERROR]
    [ODBC][31473][1339581606.491358][SQLGetDiagRec.c][680]
    Entry:
    Connection = 0x26c2a30
    Rec Number = 1
    SQLState = 0x7fff128461c0
    Native = 0x7fff12845fb4
    Message Text = 0x7fff12845fc0
    Buffer Length = 510
    Text Len Ptr = 0x7fff12846210
    [ODBC][31473][1339581606.491395][SQLGetDiagRec.c][717]
    Exit:[SQL_SUCCESS]
    SQLState = 08001
    Native = 0x7fff12845fb4 -> 0
    Message Text = [[unixODBC][FreeTDS][SQL Server]Unable to connect to data source]
    [ODBC][31473][1339581606.491442][SQLGetDiagRec.c][680]
    Entry:
    Connection = 0x26c2a30
    Rec Number = 2
    SQLState = 0x7fff128461c0
    Native = 0x7fff12845fb4
    Message Text = 0x7fff12845fc0
    Buffer Length = 510
    Text Len Ptr = 0x7fff12846210
    [ODBC][31473][1339581606.491493][SQLGetDiagRec.c][717]
    Exit:[SQL_SUCCESS]
    SQLState = 01000
    Native = 0x7fff12845fb4 -> 20013
    Message Text = [[unixODBC][FreeTDS][SQL Server]Unknown host machine name.]
    [ODBC][31473][1339581606.491528][SQLGetDiagRec.c][680]
    Entry:
    Connection = 0x26c2a30
    Rec Number = 3
    SQLState = 0x7fff128461c0
    Native = 0x7fff12845fb4
    Message Text = 0x7fff12845fc0
    Buffer Length = 510
    Text Len Ptr = 0x7fff12846210
    [ODBC][31473][1339581606.491558][SQLGetDiagRec.c][717]
    Exit:[SQL_NO_DATA]
    [ODBC][31473][1339581606.491623][SQLDisconnect.c][208]
    Entry:
    Connection = 0x26c2a30
    [ODBC][31473][1339581606.491652][SQLDisconnect.c][237]Error: 08003
    [ODBC][31473][1339581606.491719][SQLFreeHandle.c][284]
    Entry:
    Handle Type = 2
    Input Handle = 0x26c2a30
    [ODBC][31473][1339581606.491750][SQLFreeHandle.c][333]
    Exit:[SQL_SUCCESS]
    [ODBC][31473][1339581606.493083][SQLFreeHandle.c][219]
    Entry:
    Handle Type = 1
    Input Handle = 0x26abfe0
    I can also ping both the hostname and ip address of the MSSQL server.

Maybe you are looking for