Author |
Topic |
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2002-01-01 : 23:23:31
|
Jetender Sambyal writes "I am sending you below mentioned query which works okey in oracle but giving error in sql server 7.0Query:------------CREATE VIEW PAY_VWYTDDETLHIST ( CMP_CODE, FIN_YEAR, ECODE, YTDCODE, YTDTYPE, YTDAMT ) AS select CMP_CODE,FIN_YEAR,ECODE,YTDCODE,YTDTYPE,YTDAMT from pay_YTDDETLUNION ALLselect CMP_CODE,FIN_YEAR,ECODE,RECSUBCODE,RECSUBTYPE,RECSUBAMT from pay_payrecsub where (cmp_code,fin_year,ecode,pmon,pyear) in ( select cmp_code,fin_year,ecode,pmon,pyear from pay_payhist where posted ='N')UNION ALLselect CMP_CODE,FIN_YEAR,ECODE,ALLDEDCODE,ALLDEDTYPE,ALLDEDAMT+ALLDEDARR from pay_payALLDED where (cmp_code,fin_year,ecode,pmon,pyear) in ( select cmp_code,fin_year,ecode,pmon,pyear from pay_payhist where posted ='N')------------------------------------------error is :-----Server: Msg 170, Level 15, State 1, Procedure PAY_VWYTDDETLHIST, Line 6Line 6: Incorrect syntax near ','.Server: Msg 170, Level 15, State 1, Procedure PAY_VWYTDDETLHIST, Line 8Line 8: Incorrect syntax near ','.----------------------waiting for the positive reply." |
|
Nazim
A custom title
1408 Posts |
Posted - 2002-01-02 : 00:11:26
|
the Codes in Bold are not supported in Sql Serveri meanselect * from table where(column1,column2) in (select column1,column2 from anothertable) will work in Oraclebut if you want to do similar thing in Sql server then you have to separetly check itselect * from table wherecolumn1 in (select column1 from anothertable) orcolumn2 in (select column2 from anothertable) CREATE VIEW PAY_VWYTDDETLHIST ( CMP_CODE, FIN_YEAR, ECODE, YTDCODE, YTDTYPE, YTDAMT ) AS select CMP_CODE,FIN_YEAR,ECODE,YTDCODE,YTDTYPE,YTDAMT from pay_YTDDETLUNION ALLselect CMP_CODE,FIN_YEAR,ECODE,RECSUBCODE,RECSUBTYPE,RECSUBAMT from pay_payrecsub where (cmp_code,fin_year,ecode,pmon,pyear) in ( select cmp_code,fin_year,ecode,pmon,pyear from pay_payhist where posted ='N')UNION ALLselect CMP_CODE,FIN_YEAR,ECODE,ALLDEDCODE,ALLDEDTYPE,ALLDEDAMT+ALLDEDARR from pay_payALLDED where (cmp_code,fin_year,ecode,pmon,pyear) in ( select cmp_code,fin_year,ecode,pmon,pyear from pay_payhist where posted ='N') HTH |
|
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2002-01-02 : 09:32:51
|
it would be (just guessing about what you want)Also be careful about in clauses - if they contain a null then they never return anything.select * from table where exists(select * from anothertable t2 where table.column1 = t2.column1 and table.column2 = t2.column2and t2.field = 'N')==========================================Cursors are useful if you don't know sql.Beer is not cold and it isn't fizzy. |
|
|
|
|
|