Hi.I'm a casual sql user. I have found a situation where I need to convert anoracle statement to tsql, one I can just fire off in any sql tool against anms sql server database.I studied the exists statement and I think I understand it somewhat, however Iwas not sure how to get it quite right. If you have an idea and a minute ortwo I'd appreciate any insight or tutorial.insert into authorization (program, optiontitle, usergroup, authorizationid)select 'EVERYWHERE','NAVIGATOR',usergroup, authorizationseq.nextvalfrom allgroups where exists (select * from authorizationwhere authorization.USERGROUP = allgroups.USERGROUP andauthorization.optiontitle = 'READ' and authorization.program = 'EVERYWHERE')I believe that because in my data, three values of usergroup from allgroupsreturn true from the exists, that this is supposed to insert three rows intoauthorization.But I can't figure out what to do about the authorization.nextval.. I triedvarious max(authorization)+1etc but nothing seemed to compile/workthanksJeff Kish
All,Oracle 9i provides a "USING" clause option for inner joins, thatallows me to say:SELECT * FROM TBL1 JOIN TBL2 USING KeyColumnassuming KeyColumn is in both TBL1 and TBL2. This is HIGHLY desirablefor our software make use of, but we also support SQL Server. Thereis no USING option available, andSELECT * FROM TBL1 JOIN TBL2 ON TBL1.KeyColumn = TBL2.KeyColumncauses an ambiguous column error on KeyColumn.Is there any equivalent to this Oracle functionality on SQL Server?KingGreg
Is there an equivalent to Oracle's ROWNUM in SQL Server. ROWNUM, when added to a select statement as a column - the query would return an automatic counter, numbering each row returned.
I have a SQL Server database which has one user (UserA) which owns some tables. I've added an additional user (UserB) to the database such that it has access to the tables owned by UserA. What is happening is that when I log on as UserB I have to fully qualify table names and fields in my SQL statements when I deal with tables owned by UserA. Is there a way make the tables accessible without specifying the owner? In Oracle you could create a public synonym for the table eg. <table_name>. Wherever that synonym is referenced the DBMS would know thats its refering to UserA.<table_name>. Is such functionality available in SQL Server? Thanks.
I know I can limit the output rows in SQL Server by using TOP n. But I also want to generate a sequence no. The identity property of SQL Server will not be usefull here because my actaul WHERE clause will be more complex like WHERE resigndate = '01-jan-2004'
Hello,I would like to know if the equivalent Oracle rownum exist inSQLServer. Here is a sample SQL code to explain what I want to do :selectjobs.name,jobs.job_id,jobs.description,hist.message,hist.step_name,hist.step_id,hist.run_status,hist.run_date,hist.run_time,hist.run_durationfrommsdb.dbo.sysjobs jobs,msdb.dbo.sysjobhistory histwherejobs.job_id=hist.job_idand hist.job_id='E71CCB97-81C3-46E2-83FA-BFFCB66B47F8'order byrun_date, run_timeI just want the first or second row returned by this query. In Oracle Ican simply add rownum=1 or rownum=2 in the where clause to obtain thedesired answer. I don't know how to do in SQLServer.Thank in advance,Pierig.
I am having trouble creating an INSTEAD OF trigger in SQL Server toreplicate a BEFORE UPDATE trigger from ORACLE.Here is a sample of the ORACLE BEFORE UPDATE trigger:CREATE TRIGGER myTRIGGER ON MYTABLEbegin:new.DT := SYSDATE;if :new.NM is NULL then:new.NM := USER;end if;end myTRIGGER;It seems as though I have to jump through hoops in SQL Server AND Icannot come up with correct results.Here is a snippet from SQL SERVER (this is what I figured I needed todo after reading various articles,questions):CREATE TRIGGER myTRIGGER on THETABLEINSTEAD OF UPDATEASSELECT * INTO #MYTABLE FROM INSERTEDUPDATE #MYTABLE SET DT = GETDATE()UPDATE #MYTABLE SET NM = USER WHERE NM IS NULLUPDATE THETABLESETDT = (SELECT DT FROM #MYTABLE),NM = (SELECT NM FROM #MYTABLE)WHERE THETABLE.ID = (SELECT ID FROM #MYTABLE)Can anyone please shed some light on this? Thanks in advance.
I know you can start SQLCMD with the -e option to have the SQL code echoed in the output when running. Is there a way to turn this on or off within a script file? Example: File1.sql = select 'hi' as HI go File2.sql = select 'by' as BY_ go
Runfile.sql = set (like echo on, -e sign on parm) ? what command :r File1.sql set (like echo off, -e sign on parm not used) ? what command :r File2.sql
want to get output like select 'hi' as HI (echoed the select statement) HI -- hi (1 rows affected) BY_ ( did not echo the select statment) --- by
I am currently migrating my database from oracle to MSSQL. My problem is that i have encountered the UTL_FILE function in Oracle and i am not finding its equivalent for MSSQL.
Can anyone help me with this plz? Is there any other way of reading and writting OS files in MSSQL?
string2 is the substring to search for in string1.
start_position is the position in string1 where the search will start. This argument is optional. If omitted, it defaults to 1. The first position in the string is 1. If the start_position is negative, the function counts back start_position number of characters from the end of string1 and then searches towards the beginning of string1.
nth_appearance is the nth appearance of string2. This is optional. If omiited, it defaults to 1.
In SQL Server, we are having CHARINDEX and PATINDEX functions. But they will not accept the fourth paremeter (nth_appearance)
I want to know the equivalent of the Oracle translate function in SQL Server.
eg : select translate('entertain', 'et', 'ab') from dual.
I tried the SQL Server Replace function , but it replaces only one character or a sequence of character and not each occurrence of each of the specified characters given in the second argument i.e 'et'.
Please let me know if there is some other equivalent function in SQL Server
I want to know the equivalent of the Oracle translate function in SQL Server.
eg : select translate('entertain', 'et', 'ab') from dual.
I tried the SQL Server Replace function , but it replaces only one character or a sequence of character and not each occurrence of each of the specified characters given in the second argument i.e 'et'.
Please let me know if there is some other equivalent function in SQL Server
I need time in the formate HH:mm AM (ex: 06:25 AM, 08:30 PM)
I have tryed with the following query "SELECT right(CONVERT( varchar, getDate(), 100),7)" it is giving time like 6:25 AM, But I need in the format 06:25 AM.
I need exaclty equivalent of following oracle query. TO_CHAR(sysdate,'HH:mm AM')
i had worked on oracle 8i and i am planning to work on sql server 2000,i am requested by a company to help in converting there pl/sql code of oracle 8.0 to something equivalent which works on sql server 7.0 as they want to have similar code on both..i had not worked on sql server 7.0 ,but as pl/sql code works only on oracle stuff..so could kindly anyone guide me in this as to whether there is any product which coverts pl/code (the existing pl/code runs into thousands of line) automatically..i will be very grateful if anyone can enlighten me with such a product(software) or script.. along with its information and site address..any resources and any guidance as to how to go about about this conversion will be very invaluable..hope to hear soon from you guys...early response....will be appreciated..
Hi.I need to give my customer an sql file that they can run in query analyzer.All the stuff they need to run is in a set of existing files.I'd like to just tell them to load this file (this is oracle syntax):@file1.sql@file2.sql@file3.sqlis there some way of calling these files (that are in the same dir) from amaster sql file?ThanksJeff Kish
Hi what is the MSSQL eqivalent for this MSAccess Query 1 UPDATE tbl1, tbl2 SET 2 tbl1.ADJUSTED = tbl2.Code, 3 tbl1.CODE = tbl2.Code, 4 tbl1.OTHER_CODE = tbl2.Other_Code, 5 tbl1.STATUS = 'Check', tbl1.ORGK = Null, 6 tbl1.SOURCE = 'Manual' 7 WHERE (((tbl1.STATUS)='Invalid') AND 8 ((tbl2.Override)=0) AND 9 ((tbl1.Path) Like tbl2.webadmin_path))
Hello all, I'm making a query for this application that is not in the same server where the database is located.
This query I can easily get results when making the query within the server:
USE ADW_Publish; SELECT distinct b.Subject FROM dbo.F_Class_Exam a LEFT OUTER JOIN dbo.D_Course_Catalog b ON a.Course_ID = b.Course_ID WHERE a.Term = '$536870994$' AND a.Class_Exam_Type = 'FIN' AND b.Term = '$536870994$' ORDER BY b.Subject
Here are the details: Servername: SERVER01
What would an equivalent query be if I apply this to an external application (located outside the server?)
I've gotten some hints to use: SELECT * FROM OPENDATASOURCE('MSDASQL', 'DataSource=DataSourceName;UserID=User;Password=SomePassword').DBName.dbo.TableName
But I dont know how to apply the query above to use that..
Any thoughts? Or are there other ways of doing it?
Within a VS 2003 BI project, I can create a parmeterized query against an Oracle 7 database by using a ? for the parameter(s). Example: SELECT LTrim(RTrim(SWO_ISS.REF)) ACCT, CUS_LOC.NAME CUSTOMER, SWO_ISS.TRAN_DATE, SWO_ISS.ITEM, ITM_DESC.ITEM_DESCRIPTION, SWO_ISS.QTY, LSTPRC.AMT FROM MYDB.SWO_ISS, MYDB.CUS_LOC, MYDB.ITM_DESC, (SELECT LP.ITEM, LP.REVISION, LP.AMT FROM MYDB.LIST_PRC LP WHERE LP.EFFEND > SYSDATE) LSTPRC WHERE SWO_ISS.REF = CUS_LOC.CUS_LOC(+) AND SWO_ISS.COMP_ITEM = ITM_DESC.ITEM(+) AND SWO_ISS.COMP_ITEM = LSTPRC.ITEM(+) AND SWO_ISS.COMP_REV = LSTPRC.REVISION(+) AND SWO_ISS.REF = ? AND SWO_ISS.TRAN_DATE >= TO_DATE(?,'MM/DD/YYYY') AND SWO_ISS.TRAN_DATE <= TO_DATE(?,'MM/DD/YYYY')
Unfortunately, as soon as the dataset is saved or Layout view is selected the Field List disappears and all of the report objects lose their data binding. Worse still, if you click the Generic Query Designer button while working with one of these queries Visual Studio will lock up.
This worked at one time and now has me stumped. What may be the cause of the change?
I want to write this query in sql server. Please help me, it is very urgent :(
Any help will be appreciated.
SELECT VALID_ITEM.PC_CODE,PC_TITLE,VALID_ITEM.DB_CONTRACT , valid_item.ITEM_NO,DESCPT,UNITS,CONTQ, CONTR_PRICE ,nz(QTD,0) as qtd,ind_ovr_und, nz(QTD,0) - NVL(QUANTITY,0) as QUANT_PREV, Nz(QUANTITY,0) as quant_rev, round(NVL(quantity,0)*nvl(CONTR_PRICE,0),2) as QTD_VAL, AMT_PAID_ITEM,AMT_RET_ITEM FROM VALID_ITEM, cqe_item,CONTRACT_PC WHERE valid_item.db_contract = contract_pc.db_contract and valid_item.pc_code = contract_pc.pc_code and valid_item.db_contract = cqe_item.db_contract (+) and cqe_item.cqe_numb (+) = :EST_NO and valid_item.item_no = cqe_item.item_no (+) and valid_item.pc_code = cqe_item.pc_code (+) order by valid_item.item_no