how to generate as "enter" function in SQLSERVER?

Answered how to generate as "enter" function in SQLSERVER?

  • יום ראשון 14 ינואר 2007 08:27
     
     

    For example:

    select 'sp_refreshview ''' + [name] +''' go ' from Sysobjects where xtype='v' order by [name]

    I want the result is follow:

    sp_refreshview 'lt.trxdetai'

    go
    sp_refreshview 'ps_account'

    go

     

    thanks


     

כל התגובות

  • יום ראשון 14 ינואר 2007 11:11
     
     

    Modify your statement to add char(13) as shown below

    select 'sp_refreshview ''' + [name] +'''' + char(13)+ 'go ' from Sysobjects where xtype='v' order by [name]

    Regards,

    sam

     

     

     

     

  • יום ראשון 14 ינואר 2007 20:24
     
     תשובה
    You can do below and use the text mode output. There is no need to put CR and LF.
     
    select 'exec sp_refreshview ''' + [name] +''';' from sysobjects where xtype='v' order by [name]
     
    If you need to generate the call as different batches then simply add a CR & LF as part of the string itself like:
     
    select 'exec sp_refreshview ''' + [name] +'''
    go
    '
    from sysobjects where xtype='v' order by [name]