none
Open query

    Soru

  • SET @SQLStmt 'INSERT INTO #solnWS 
    		SELECT 
    		GL.DEL_DOC_NUM,
    		GL.DEL_DOC_LN#,
    		GL.SO_WR_DT,	
    		GL.ADDON_WR_DT,	
    		GL.ITM_CD,
    		GL.SO_STORE_CD,
    		GL.SO_DOC_NUM,	
    		GL.UNIT_PRC,
    		CASE GL.DC_CD WHEN ''D'' THEN GL.QTY ELSE -1 * GL.QTY END AS QTY,
    		GL.TAKEN_WITH,
    		GL.ORD_TP_CD,
    		GL.OUT_ID_CD,
    		GL.FIFO_CST,
    		ISNULL( dbo.GetMPRowID( GL.ITM_CD, GL.SO_WR_DT, GL.FINAL_DT ), 0 ) AS MP_ROW_ID
    		
    		FROM 
    			OpenQuery( GERS_LIVE, ''' + @GERSStmt + ''') GL'
    
    
    I dont want to use  FROM OpenQuery( GERS_LIVE, ''' + @GERSStmt + ''') GL'
    
    I changed my @GERSStmt it was an open query but i wont be needed to query from Linked server.. My question is how can i Insert the above wihtout open query


    FM

    06 Mart 2012 Salı 21:01

Yanıtlar

  • so what is the question? :)

    If you want to call the open query, so your syntax seems fine. (just make sure the number of "''" is correct, because you have here a "" inside a text that is already in "", so you have to make sure you test the string and it gives you the correct results.


    Shoshi r

    • Yanıt Olarak İşaretleyen KJian_ 13 Mart 2012 Salı 02:58
    06 Mart 2012 Salı 22:32

Tüm Yanıtlar

  • I'm not sure your question is clear enough,

    is the  @GERSStmt calling a table from your local SQLServer?

    if it does, the code you have to write should be:

    SET @SQLStmt 'INSERT INTO #solnWS 
    		SELECT 
    		GL.DEL_DOC_NUM,
    		GL.DEL_DOC_LN#,
    		GL.SO_WR_DT,	
    		GL.ADDON_WR_DT,	
    		GL.ITM_CD,
    		GL.SO_STORE_CD,
    		GL.SO_DOC_NUM,	
    		GL.UNIT_PRC,
    		CASE GL.DC_CD WHEN ''D'' THEN GL.QTY ELSE -1 * GL.QTY END AS QTY,
    		GL.TAKEN_WITH,
    		GL.ORD_TP_CD,
    		GL.OUT_ID_CD,
    		GL.FIFO_CST,
    		ISNULL( dbo.GetMPRowID( GL.ITM_CD, GL.SO_WR_DT, GL.FINAL_DT ), 0 ) AS MP_ROW_ID
    		
    		FROM 
    			''' + @GERSStmt + '''  GL'


    Shoshi r

    06 Mart 2012 Salı 22:03
  • Hi Shoshi,

    @GERSStmt  = Was calling a table from an Oracle Schema..

    select * from openquery(LS,'Select * from emp')

    basically i omitted open query with  select * from [ls].[emp]


    FM

    06 Mart 2012 Salı 22:20
  • so what is the question? :)

    If you want to call the open query, so your syntax seems fine. (just make sure the number of "''" is correct, because you have here a "" inside a text that is already in "", so you have to make sure you test the string and it gives you the correct results.


    Shoshi r

    • Yanıt Olarak İşaretleyen KJian_ 13 Mart 2012 Salı 02:58
    06 Mart 2012 Salı 22:32