Msg 116, Level 16, State 1, Line 6 Only one expression can be specified in the select list when the subquery is not introduced with EXISTS.

Hello,
Can anyone help me?
select year(po.rdata) as 'Ano', 
sum(etotal) as 'Valorp' ,
(select year(fo.data),Sum(etotal) 
FROM fo (nolock) 
where  not exists ( select 1 from pl (nolock) where pl.adoc = fo.adoc and pl.cm = fo.doccode ) 
group by year(fo.data))as 'Valorap'   
from po 
group by year(po.rdata)
order by year(po.rdata)
Error 
Msg 116, Level 16, State 1, Line 6
Only one expression can be specified in the select list when the subquery is not introduced with EXISTS.
Consultora

Hi Prashanth,
select year(po.rdata) as 'Ano',
sum(etotal) as 'Valorp' ,
(select Sum(etotal)
FROM fo (nolock)
where not exists ( select 1 from pl (nolock) where pl.adoc = fo.adoc and pl.cm = fo.doccode )
group by year(fo.data))as 'Valorap'
from po(nolock)
group by year(po.rdata)
order by year(po.rdata)
Gives me the error: 
Msg 512, Level 16, State 1, Line 1
Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.
Thanks
Consultora

Similar Messages

  • Only one expression can be specified in the select list when the subquery is not introduced with EXISTS.

    hi all
    i have a table that name is:
    TiketsHeader 
    but i used this code
    SELECT TicketsHeaderId, Active, TH.PersonRef,P.Fname + ' ' + P.Lname AS NF, Serial, TicketsCnt, StartSerial, EndSerial, KindDate, StratDate, EndDate,
    MonthsRef1,(SELECT * FROM dbo.Months M WHERE M.MonthsId= MonthsRef1 ) AS MonthsName1 , MonthsRef2, MonthsRef3, WeekDaysRef,
    PoolTimesRef, TH.Descreption
    FROM dbo.TiketsHeader TH
    INNER JOIN Person P ON P.PersonId= TH.PersonRef
    i see this error:
    Msg 116, Level 16, State 1, Line 2
    Only one expression can be specified in the select list when the subquery is not introduced with EXISTS.
    how to solve it
    please help me
    Name of Allah, Most Gracious, Most Merciful and He created the human

    SELECT TicketsHeaderId, Active, TH.PersonRef,P.Fname + ' ' + P.Lname AS NF, Serial, TicketsCnt, StartSerial, EndSerial, KindDate, StratDate, EndDate,
    MonthsRef1,(SELECT * FROM dbo.Months M WHERE M.MonthsId= MonthsRef1 ) AS MonthsName1 , MonthsRef2, MonthsRef3, WeekDaysRef,
    PoolTimesRef, TH.Descreption
    FROM dbo.TiketsHeader TH
    INNER JOIN Person P ON P.PersonId= TH.PersonRef
    A Sub query like this can only return one column, not serveral like here with the star *. Replace the star by one column Name that you want to query.
    Olaf Helper
    [ Blog] [ Xing] [ MVP]

  • Finding this error when running the below query - Only one expression can be specified in the select list when the subquery is not introduced with EXISTS.

    select 
    min(h.[Spcl Order]),
    (select (case when sum(pro.[Quantity]) is null then 0 else sum(pro.[Quantity]) END))
    +
    (select (case when sum(A.[Quantity]) is null then 0 else sum(A.[Quantity]) END),
    min(b.[Posting Date]),min(c.[Order No]),min(d.[Prod_Order No]),min(e.[No]),
    min(f.[Item Category Code]),min(g.[Location Code]),min(i.[Spcl Order_Purch])
    from [tablename2] A 
    inner join [sample].[dbo].[Posting Date_PRL] as b on a.[Posting Date]=b.[Posting Date]
    inner join [sample].[dbo].[Order No_PRL] as c on a.[Order No_]=c.[Order No]
    inner join [sample].[dbo].[Prod_ OrderNo_PRL] as d on a.[Prod_ Order No_]=d.[Prod_OrderNo] 
    inner join [sample].[dbo].[No_PRL] as e on a.[No_]=e.[No]
    inner join [sample].[dbo].[Item Category Code_PRL] as f on a.[Item Category Code]=f.[Item Category Code]
    inner join [sample].[dbo].[Location Code_PRL] as g on a.[Location Code]=g.[Location Code]
    inner join [sample].[dbo].[Spcl Order_PRL] as i on a.[Spcl Order]=i.[Spcl Order_Purch]
    where ((A.[Item Category Code] = 'STYLES') and (A.[Prod_ Order No_]='') and ( A.[Buy-from Vendor No_] in ('S02052')) AND (A.[Quantity]>0) 
    AND ( A.[Posting Date] = pro.[Finished Date])))
    from [tablename1] pro 
    inner join [sample].[dbo].[Spcl Order_PO] as h on Pro.[Spcl Order]=h.[Spcl Order]
    where ((pro.[Status]=4) and (pro.[Finished Date] ='2013-10-10' )) group by pro.[Finished Date]

    As other suggested, please find the column list...there are many columns in your subquery...
    eg:
    Select *,(Select 1,2) From (Values(1),(2))A(MonthID) -- will not work
    where as 
    Select *,(Select 1) From (Values(1),(2))A(MonthID) --will work
    Your case:
    select 
    min(h.[Spcl Order]),
    (select
    (case when sum(pro.[Quantity]) is null then 0 else sum(pro.[Quantity]) END))
    +
    (select (case when sum(A.[Quantity]) is null then 0 else sum(A.[Quantity]) END),
    min(b.[Posting Date]),min(c.[Order No]),min(d.[Prod_Order No]),min(e.[No]),
    min(f.[Item Category Code]),min(g.[Location Code]),min(i.[Spcl Order_Purch])
    from [tablename2] A 
    inner join [sample].[dbo].[Posting Date_PRL] as b on a.[Posting Date]=b.[Posting Date]
    inner join [sample].[dbo].[Order No_PRL] as c on a.[Order No_]=c.[Order No]
    inner join [sample].[dbo].[Prod_ OrderNo_PRL] as d on a.[Prod_ Order No_]=d.[Prod_OrderNo] 
    inner join [sample].[dbo].[No_PRL] as e on a.[No_]=e.[No]
    inner join [sample].[dbo].[Item Category Code_PRL] as f on a.[Item Category Code]=f.[Item Category Code]
    inner join [sample].[dbo].[Location Code_PRL] as g on a.[Location Code]=g.[Location Code]
    inner join [sample].[dbo].[Spcl Order_PRL] as i on a.[Spcl Order]=i.[Spcl Order_Purch]
    where ((A.[Item Category Code] = 'STYLES') and (A.[Prod_ Order No_]='') and ( A.[Buy-from Vendor No_]
    in ('S02052')) AND (A.[Quantity]>0) 
    AND ( A.[Posting Date] = pro.[Finished Date])))
    from [tablename1] pro 
    inner join [sample].[dbo].[Spcl Order_PO] as h on Pro.[Spcl Order]=h.[Spcl Order]
    where ((pro.[Status]=4) and (pro.[Finished Date] ='2013-10-10' )) group by pro.[Finished Date]

  • Error Only one expression can be specified in the expression list when the subquery is not intriduced. Please help

    Please help to fix this error
    SELECT    A.FLEETID,
    (SELECT   b.fleetid,SIZE,MAKE,PATTERN FROM ROQFLEETCHECK B
             WHERE  B.AxleNo=1  and B.AxleType = 'OFFSIDE OUTER' AND B.FLEETID = 1819 and B.fleetid =  A.fleetid) AS fleetList
    FROM ROQFLEETCHECK    AS A WHERE  a.FLEETID = 1819;
    Regards
    Pol
    polachan

    Hi,
    In addition to
    Naarasimha's answer. a small clarification: As much as the query optimizer the sub query "SELECT...
    FROM ROQFLEETCHECK B WHERE  ..."  might return more then one value and therefore it raise this error. What you can do, is limit
    the returned value to one, using "top 1" or aggregate function (as
    Naarasimha suggested).
      Ronen Ariely
     [Personal Site]    [Blog]    [Facebook]

  • Query in SQL 2008R2 error Msg 1087, Level 15, State 2, Line 31 Must declare the table variable

    Hello Experts, 
    Can You help me; I get the follwing error in my query
    Msg 1087, Level 15, State 2, Line 31
    Must declare the table variable "@ASE_SUBART_GROEP".
    the @ASE_SUBART_GROEP is a self-defined table in this SQL environment.
    Maybe you know the error or the missing part
    Thanks in advance, Jos Dielemans

    I'm not familiar with SAP Business One unfortunately, so can only be of limited help here. But I'm going to guess that @ASE_SUBART_GROEP is a table variable passed to a stored procedure and is defined and passed down by the application, so you won't
    be able to copy-paste this code directly into management studio and get it to work.
    You could remove the join to return *all* records. Although the dataset might be very big
    SELECT T0.CardCode AS 'Klantnr'
    ,T0.CardName AS 'Klantnaam'
    ,T4.GroupName AS 'Klantgroep'
    ,T9.Descr AS 'Merknaam'
    ,T5.SlpName AS 'Verkoper'
    ,T3.MailCity AS 'Leverplaats'
    ,T7.NAME AS 'Leverland'
    ,T3.City AS 'Factuurplaats'
    ,T7.NAME AS 'Factuurland'
    ,T0.DocNum AS 'Documentnr'
    ,T0.DocDate AS 'Datum'
    ,Cast((Datepart(Year, T0.DocDate)) AS VARCHAR) AS 'Jaar'
    ,RIGHT('00' + CAST(DATEPART(MONTH, T0.DocDate) AS VARCHAR(2)), 2) AS 'Maand'
    ,(Cast((Datepart(Year, T0.DocDate)) AS VARCHAR) + '-' + RIGHT('00' + CAST(DATEPART(MONTH, T0.DocDate) AS VARCHAR(2)), 2)) AS 'Periode'
    ,T1.ItemCode AS 'Artikelnr'
    ,T2.ItemName AS 'Artikelnaam'
    ,T1.Quantity AS 'Aantal VEH'
    ,T2.SVolume AS 'Aantal EH per VEH'
    ,(T1.Quantity * T2.SVolume) AS 'Aantal EH'
    ,T8.UnitName AS 'EH-Naam'
    ,T6.ItmsGrpNam AS 'Artikelgroep'
    ,T2.U_ItemGrp AS 'Hoofdgroep'
    ,T10.NAME AS 'Subgroep'
    ,T1.CogsAcct AS 'Kostpr.rek.'
    ,T1.AcctCode AS 'Opbrengstrek.'
    ,T1.LineTotal AS 'BrutoOmzet'
    ,T0.DiscPrcnt AS 'Korting'
    ,(+ T1.LineTotal * (100 - T0.DiscPrcnt) / 100) AS 'NettoOmzet'
    FROM dbo.OINV T0
    INNER JOIN dbo.INV1 T1 ON T0.DocEntry = T1.DocEntry
    INNER JOIN OITM T2 ON T1.ItemCode = T2.ItemCode
    INNER JOIN OCRD T3 ON T0.CardCode = T3.CardCode
    INNER JOIN OCRG T4 ON T3.GroupCode = T4.Groupcode
    INNER JOIN OSLP T5 ON T3.SlpCode = T5.SlpCode
    INNER JOIN OITB T6 ON T2.ItmsGrpCod = T6.ItmsGrpCod
    INNER JOIN OCRY T7 ON T3.Country = T7.Code
    LEFT OUTER JOIN OLGT T8 ON T2.SVolUnit = T8.UnitCode
    LEFT OUTER JOIN UFD1 T9 ON T3.U_ZPgroep = T9.FldValue
    AND TableID = 'OCRD'
    AND FieldID = 2
    --LEFT OUTER JOIN @ASE_SUBART_GROEP T10 ON T2.U_ASE_SUB_ARTGROEP = T10.Code
    WHERE T0.DocDate >= '20120101'
    AND T0.Canceled = 'N'
    UNION ALL
    SELECT T0.CardCode AS 'Klantnr'
    ,T0.CardName AS 'Klantnaam'
    ,T4.GroupName AS 'Klantgroep'
    ,T9.Descr AS 'Merknaam'
    ,T5.SlpName AS 'Verkoper'
    ,T3.MailCity AS 'Leverplaats'
    ,T7.NAME AS 'Leverland'
    ,T3.City AS 'Factuurplaats'
    ,T7.NAME AS 'Factuurland'
    ,T0.DocNum AS 'Documentnr'
    ,T0.DocDate AS 'Datum'
    ,Cast((Datepart(Year, T0.DocDate)) AS VARCHAR) AS 'Jaar'
    ,RIGHT('00' + CAST(DATEPART(MONTH, T0.DocDate) AS VARCHAR(2)), 2) AS 'Maand'
    ,(Cast((Datepart(Year, T0.DocDate)) AS VARCHAR) + '-' + RIGHT('00' + CAST(DATEPART(MONTH, T0.DocDate) AS VARCHAR(2)), 2)) AS 'Periode'
    ,T1.ItemCode AS 'Artikelnr'
    ,T2.ItemName AS 'Artikelnaam'
    ,- T1.Quantity AS 'Aantal VEH'
    ,T2.SVolume AS 'Aantal EH per VEH'
    ,(- T1.Quantity * T2.SVolume) AS 'aantal EH'
    ,T8.UnitName AS 'EH-Naam'
    ,T6.ItmsGrpNam AS 'Artikelgroep'
    ,T2.U_ItemGrp AS 'Hoofdgroep'
    ,T10.NAME AS 'Subgroep'
    ,T1.CogsAcct AS 'Kostpr.rek.'
    ,T1.AcctCode AS 'Opbrengstrek.'
    ,- T1.LineTotal AS 'BrutoOmzet'
    ,T0.DiscPrcnt AS 'Korting'
    ,(+ T1.LineTotal * (100 - T0.DiscPrcnt) / 100) AS 'NettoOmzet'
    FROM dbo.ORIN T0
    INNER JOIN dbo.RIN1 T1 ON T0.DocEntry = T1.DocEntry
    INNER JOIN OITM T2 ON T1.ItemCode = T2.ItemCode
    INNER JOIN OCRD T3 ON T0.CardCode = T3.CardCode
    INNER JOIN OCRG T4 ON T3.GroupCode = T4.Groupcode
    INNER JOIN OSLP T5 ON T3.SlpCode = T5.SlpCode
    INNER JOIN OITB T6 ON T2.ItmsGrpCod = T6.ItmsGrpCod
    INNER JOIN OCRY T7 ON T3.Country = T7.Code
    LEFT OUTER JOIN OLGT T8 ON T2.SVolUnit = T8.UnitCode
    LEFT OUTER JOIN UFD1 T9 ON T3.U_ZPgroep = T9.FldValue
    AND TableID = 'OCRD'
    AND FieldID = 2
    --LEFT OUTER JOIN @ASE_SUBART_GROEP T10 ON T2.U_ASE_SUB_ARTGROEP = T10.Code
    WHERE T0.DocDate >= '20120101'
    AND T0.Canceled = 'N'
    ORDER BY T0.CardCode
    The join to the table variable has been commented out above, so the code should run. After that you might want to update the WHERE clause to include only particular sub-groups

  • Msg 102, Level 15, State 1, Line 1

    There is index rebuild anr reorzine index following error showing.Early days it was working fine.
    Executed: ALTER INDEX [L_CONFI_HIST_PK] ON [dbo].[L_CONFI_HIST] REBUILD PARTITION=6 PARTITION=2
    Msg 102, Level 15, State 1, Line 1
    Incorrect syntax near 'PARTITION'.

    As others suggested, you can not REBUILD more than 1 partition without specifying ALL.
    Excerpt:
    PARTITION
    Specifies that only one partition of an index will be rebuilt or reorganized. PARTITION cannot be specified if index_name is not a partitioned
    index.
    Ref: https://technet.microsoft.com/en-us/library/ms188388(v=sql.105).aspx
    Please mark this reply as answer if it solved your issue or vote as helpful if it helped.
     [Blog]

  • I am geeting problem whem i run bulk insert query i got error Location:_ bcpimp.cpp:1797 Expression:_ cbOutTemp cbOutputStr SPID:__ 52 Process ID:_ 2364 Msg 3624, Level 20, State 1, Line 3 A system assertion check has failed. Check the SQL Server error

    Location: bcpimp.cpp:1797
    Expression: cbOutTemp < cbOutputStr
    SPID: 52
    Process ID: 2364
    Msg 3624, Level 20, State 1, Line 3
    A system assertion check has failed. Check the SQL Server error log for details. Typically, an assertion failure is caused by a software bug or data corruption. To check for database corruption, consider running DBCC CHECKDB. If you agreed to send dumps to
    Microsoft during setup, a mini dump will be sent to Microsoft. An update might be available from Microsoft in the latest Service Pack or in a QFE from Technical Support. 
    Msg 0, Level 20, State 0, Line 0
    A severe error occurred on the current command.  The results, if any, should be discarded.

    If you check your sql server error log folder you will see dump files created. You need to send those dump files to Microsoft for inspection because outside of microsoft product support the symbols for reading the dumps are not available without which it
    wont be easy to find the issue.
    http://support.microsoft.com/kb/2028589
    In the meantime check if you are on the latest version of Service Pack and if not apply the latest service pack. Majority of these kind of assertions are bugs which are solved in Service Packs/Cumulative Updates.
    Regards, Ashwin Menon My Blog - http:\\sqllearnings.com

  • Increase the DB size in Azure gives the Error " Msg 40197, Level 16, State 1, Line 1 The service has encountered an error processing your request. Please try again. Error code 40671."

    Increase the DB size in Azure gives the following error
    Msg 40197, Level 16, State 1, Line 1 The service has encountered an error processing your request. Please try again. Error code 40671.
    i have used following ALTER query,
    ALTER DATABASE database_name MODIFY (EDITION='Business', MAXSIZE=10GB);
    Regards
    Vel

    Hi Taiye,
    According to your description, in theory, we can modify the size of database, and the T-SQL statement in your post is right. So we need to verify if there is no problem with network when you execute the modification statement, in addition, you must be connected
    to the master database when executing the ALTER DATABASE statement. As the error message, I recommend you login again and connect to the master database then run the statement again.
     For more information, see: ALTER DATABASE (Windows Azure SQL Database)
    If the error is still exist, the Microsoft support engineer will help to solve the problem from backend. Sometime delay might be expected. Your patience is greatly appreciated.
    Thanks,
    Sofiya Li
    If you have any feedback on our support, please click here.
    Sofiya Li
    TechNet Community Support

  • I want to be the only one who can access my profile, so how to create passwords for profiles (NOT for websites) ?

    I want to be the only one who can access my profile, so how to create passwords for profiles (NOT for websites) ?
    thanks

    Maybe use the portable Firefox version on a USB stick if you want to prevent access to your profile.<br />
    Solutions that use an extension can easily be bypassed by starting in [[Safe mode]].<br />
    Otherwise you need to locate the Firefox profile folder on an encrypted drive.
    See http://portableapps.com/apps/internet/browsers/portable_firefox

  • Msg 530, Level 16, State 1, Line 4, The statement terminated. The maximum recursion 100 has been exhausted before statement completion.

    I wrote the query below to try and see id there is any day during the start and to date when there is no activity, but keep getting the problem above.
    declare
    @date_fromdatetime,@date_todatetime
    set
    @date_from=convert(datetime,'01/04/2014',103)
    set
    @date_to=convert(datetime,'31/12/2015',103)
    withdatesas(
    select@date_fromasdt
    unionall
    selectDATEADD(d,1,dt)fromdateswheredt<@date_to
    select
      d.dt,isnull(total_qty,0)astotal_qty
    from
    datesd
    left
    join(
    select  
    [arrival date],count(*)astotal_qty
    from    
    Customers
    where   
    [arrival date]between@date_fromand@date_to
    groupby[arrival
    date]
    sond.dt=s.[arrival
    date]
    order
    byd.dt

    In future when posting code, please post it in a code block (second button from the right).
    Also, please include example data and DDL (as I have at the top of my example).
    After cleaning up your code, and creating a demo object for you, I found that the statement itself is fine, and the problem is likely in your dates object.
    I used my calendar in place of your dates object:
    DECLARE @customers TABLE ([arrival date] DATETIME)
    INSERT INTO @customers ([arrival date]) VALUES
    ('2015-01-04'),('2015-01-05'),('2015-01-06'),('2015-01-07'),('2015-01-08'),('2015-01-07'),('2015-01-08'),('2015-01-11'),('2015-01-12')
    ;with dates as(
    select @date_from as dt
    union all
    select DATEADD(d,1,today)
    from calendar
    where today < @date_to
    SELECT *
    FROM dates d
    LEFT OUTER JOIN (
    SELECT [arrival date], COUNT(*) AS total_Qty
    FROM @customers
    WHERE [arrival date] between @date_from and @date_to
    GROUP BY [arrival date]
    ) s
    ON d.dt = s.[arrival date]
    You can find my calendar table here: http://social.technet.microsoft.com/wiki/contents/articles/29260.tsql-calendar-functions-and-tables.aspx
    Don't forget to mark helpful posts, and answers. It helps others to find relevant posts to the same question.

  • Msg 137, Level 15, State 2, Line 29 Must declare the scalar variable "@ACTIVE_STATUS".

    USE [NC_DB]
    GO
    /****** Object:  StoredProcedure [dbo].[S_EDIT_USER]    Script Date: 12/23/2013 12:32:44 ******/
    SET ANSI_NULLS ON
    GO
    SET QUOTED_IDENTIFIER ON
    GO
    ALTER PROCEDURE [dbo].[S_EDIT_USER]  
    (  @DSA_CODE VARCHAR(10)  
        ,@REQUESTOR_DEPT VARCHAR(40) 
        ,@ACTIVE_STATUS INT  
        ,@MAKER_ID VARCHAR(10)  
        ,@MAKER_IP VARCHAR(20)  
        ,@ERROR_CODE INT OUTPUT  
    AS  
    BEGIN  
    DECLARE @CNT INT;   
    DECLARE @SQL NVARCHAR(MAX);
    --DECLARE @REQUESTOR_DEPT VARCHAR(40);
    --print(@REQUESTOR_DEPT);
    SELECT @CNT = COUNT(*) FROM TMAS_UAM_USER_TMP WHERE DSA_CODE = @DSA_CODE;  
    IF @CNT > 0  
     SET @ERROR_CODE = 1;  
    ELSE  
     SET @ERROR_CODE = 0; 
    if @REQUESTOR_DEPT = 'N'
     SET @REQUESTOR_DEPT = ''; 
    ELSE  
     SET @REQUESTOR_DEPT = @REQUESTOR_DEPT ; 
     print @REQUESTOR_DEPT;
    IF @ERROR_CODE = 0
    set @SQL = 'INSERT INTO TMAS_UAM_USER_TMP (  
       DSA_CODE  
               ,DSA_NAME  
               ,DSA_CITY  
               ,DSA_PRODUCT  
               ,DSA_PHNO  
               ,DSA_MOBNO  
               ,DSA_RQSTR  
               ,DSA_RQSTR_DEPT  
               ,GROUP_ID  
               ,ACTIVE_STATUS  
               ,REQ_TYPE  
               ,LAST_LOGED_IN  
               ,CREATED_ID  
         ,CREATED_IP  
         ,CREATED_DATE  
               ,MAKER_ID  
               ,MAKER_IP  
               ,MAKER_DATE  
     ) SELECT DSA_COD  
         ,DSA_NAM  
         ,DSA_CTY  
         ,PRODUCT  
         ,DSA_PHO  
         ,DSA_MOB  
         ,REQUESTOR  
         ,'+@REQUESTOR_DEPT+'
         ,GROUP_ID  
         ,@ACTIVE_STATUS 
         ,1  
         ,LAST_LOG_DAT  
         ,CREATED_ID  
         ,CREATED_IP  
         ,CREATED_DATE  
         ,'+@MAKER_ID+'  
         ,'+@MAKER_IP+'  
         ,GETDATE()  
        FROM DSA_MST WHERE DSA_COD = '+@DSA_CODE+' and ';
    if @REQUESTOR_DEPT = 'N'
    begin
    set @SQL = @SQL + 'REQUESTOR_DEPT is null';
    print('If Query'+@SQL);
    end
    else
    begin
        set @SQL = @SQL + 'REQUESTOR_DEPT = ''' + @REQUESTOR_DEPT + '''';
        print('Else Query'+@SQL);
        end
       --EXEC sp_executesql @SQL, N'@REQUESTOR_DEPT varchar(100) output', @REQUESTOR_DEPT output
    --EXECUTE sp_executesql @SQL;
    execute (@SQL);
    RETURN @ERROR_CODE;  
    END  

    The problem is that you are using dynamic SQL which you should not. Use the
    below instead. Uncomment the query hint if you are worried about
    performance.
    ALTER PROCEDURE [dbo].[S_EDIT_USER]  
    (  @DSA_CODE VARCHAR(10)  
        ,@REQUESTOR_DEPT VARCHAR(40) 
        ,@ACTIVE_STATUS INT  
        ,@MAKER_ID VARCHAR(10)  
        ,@MAKER_IP VARCHAR(20)  
        ,@ERROR_CODE INT OUTPUT  
    AS  
    BEGIN  
    DECLARE @CNT INT;   
    --DECLARE @REQUESTOR_DEPT VARCHAR(40);
    --print(@REQUESTOR_DEPT);
    SELECT @CNT = COUNT(*) FROM TMAS_UAM_USER_TMP WHERE DSA_CODE = @DSA_CODE;  
    IF @CNT > 0  
     SET @ERROR_CODE = 1;  
    ELSE  
     SET @ERROR_CODE = 0; 
    if @REQUESTOR_DEPT = 'N'
     SET @REQUESTOR_DEPT = ''; 
    ELSE  
     SET @REQUESTOR_DEPT = @REQUESTOR_DEPT ; 
     print @REQUESTOR_DEPT;
    IF @ERROR_CODE = 0
    INSERT INTO TMAS_UAM_USER_TMP (  
       DSA_CODE  
               ,DSA_NAME  
               ,DSA_CITY  
               ,DSA_PRODUCT  
               ,DSA_PHNO  
               ,DSA_MOBNO  
               ,DSA_RQSTR  
               ,DSA_RQSTR_DEPT  
               ,GROUP_ID  
               ,ACTIVE_STATUS  
               ,REQ_TYPE  
               ,LAST_LOGED_IN  
               ,CREATED_ID  
         ,CREATED_IP  
         ,CREATED_DATE  
               ,MAKER_ID  
               ,MAKER_IP  
               ,MAKER_DATE  
     ) SELECT DSA_COD  
         ,DSA_NAM  
         ,DSA_CTY  
         ,PRODUCT  
         ,DSA_PHO  
         ,DSA_MOB  
         ,REQUESTOR  
         ,'+@REQUESTOR_DEPT+'
         ,GROUP_ID  
         ,@ACTIVE_STATUS 
         ,1  
         ,LAST_LOG_DAT  
         ,CREATED_ID  
         ,CREATED_IP  
         ,CREATED_DATE  
         ,'+@MAKER_ID+'  
         ,'+@MAKER_IP+'  
         ,GETDATE()  
        FROM DSA_MST
    WHERE DSA_COD = @DSA_CODE
     and  (REQUESTOR_DEPT = @REQUESTOR_DEPT OR @REQUESTOR_DEPT = 'N')
    -- OPTION (RECOMPILE)
    END  
    Erland Sommarskog, SQL Server MVP, [email protected]

  • Msg 701, Level 17, State 130, Line 1 There is insufficient system memory in resource pool 'default' to run this query.

      In My production I have this error ,when ever user use the Full text search , Is there any chance of  it happen because of full text , user search "S++"  but  it return several thousand un ncessary records. how to
    avoid this?
    Thanks & Regards Manoj

    See if this helps
    http://henkvandervalk.com/sql2014ee-insufficient-system-memory-message
    Please Mark This As Answer if it solved your issue
    Please Vote This As Helpful if it helps to solve your issue
    Visakh
    My Wiki User Page
    My MSDN Page
    My Personal Blog
    My Facebook Page

  • HT202157 Am I the only one who can't get their Apple TV to update the software?

    I was wondering why I cant update my Apple TV to the new software. Im thinking that it cant be updated until March 16th but im not sure.

    i updated mine just fine this morning.  what happens when you try to update?  are you getting an error, is it not finding an update, it is emitting a mild nuerotoxin that causes you to passout while gnomes steal your socks?  without more detail im not really sure how to help
    -mvimp

  • Linked Server error - Msg 7311, Level 16, State 2

    We have three SQL Servers:
    SQL 2008 Instance w/ SP1 cumulative update #5; running on Windows Server 2008 r2
    SQL 2008 Instance w/ SP1 cumulative update #5; running on Windows Server 2003 r2
    SQL 2000 Instance w/ SP4; running on Windows Server 2003 r2 W/ SP2
    We have a linked server connection from #2 to #3, which works perfectly.  However, our linked server connection from #1 to #3 does not work.  here is the error message we get:
    OLE DB provider "SQLNCLI10" for linked server "CCSSQLTEST01A" returned message "Unspecified error".
    OLE DB provider "SQLNCLI10" for linked server "CCSSQLTEST01A" returned message "The stored procedure required to complete this operation could not be found on the server. Please contact your system administrator.".
    Msg 7311, Level 16, State 2, Line 1
    Cannot obtain the schema rowset "DBSCHEMA_TABLES_INFO" for OLE DB provider "SQLNCLI10" for linked server "CCSSQLTEST01A". The provider supports the interface, but returns a failure code when it is used.
    I've read articles saying we may need to run a specific script on the server we are linking to, due to missing SPs, but how can that be possible if the other linked server connection works?  We are linking from two identical
    SQL Server instances (other than the OS)...
    The only other difference I know of, is that #1 was an upgrade from SQL 2005, but #2 was a clean install of SQL 2008.
    Suggestions? 
    Clint

    I really don't think this is the case otherwise in my .Net applications I'd have to determine the version of the target SQL server, then instantiate the appropriate connection object.  Things just don't work that way.   I'm pretty sure
    you will find that a SQL Native Client 10 provider can connect to anything from SQL 2008 and below, but not anything above (once it is released :).
    The real issue is given in the message. Cannot obtain the schema rowset "DBSCHEMA_TABLES_INFO"
    If
    you source server is 64 bit and your target is 32 bit then you will need to do the following.  (I have to pass credit to Kun Sik Lee of Costar Group for this one)
    create
    procedure sp_tables_info_rowset_64
         @table_name
    sysname,
         @table_schema    
    sysname =
    null,  
         @table_type
    nvarchar(255)
    = null
    as
    declare @Result
    int set @Result
    = 0
    exec @Result
    = sp_tables_info_rowset
    @table_name, @table_schema, @table_type
    GO
    use [master]
    GO
    GRANT
    EXECUTE ON [dbo].[sp_tables_info_rowset_64]
    TO [LinkServerUser]
    GO

  • Msg 2601, Level 14, State 1, Procedure sp_flush_commit_table, Line 15 Cannot insert duplicate key row in object 'sys.syscommittab' with unique index 'si_xdes_id'. The duplicate key value is (2238926153). The statement has been terminated.

    I am using SQL server 2008 R1 SP3. And when we are doing back up operations we are facing the below error
    Msg 2601, Level 14, State 1, Procedure sp_flush_commit_table, Line 15
    Cannot insert duplicate key row in object 'sys.syscommittab' with unique index 'si_xdes_id'. The
    duplicate key value is (2238926153).
    The statement has been terminated.
    Please assist me with your inputs.
    Thanks,
    Rakesh.

    Hello,
    Did you enable change tracking on the database? If so, please try to disable and re-enable the change tracking.
    The following thread is about the similar issue, please refer to:
    http://social.msdn.microsoft.com/forums/sqlserver/en-US/c2294c73-4fdf-46e9-be97-8fade702e331/backup-fails-after-installing-sql2012-sp1-cu1-build-3321
    Regards,
    Fanny Liu
    Fanny Liu
    TechNet Community Support

Maybe you are looking for