none
BCP copy contiaining spaces

    Question

  • I have table which has column A. "A" column sometimes contains data with spaces and tabs. Is there any way to log the error if the data contains spaces or tabs.
    Wednesday, September 11, 2013 11:10 PM

Answers

  • Hi Deepesh,

    To check whether the data contains space or tab, we can refer to the following method:

    declare @tempTb table
    (
     [A] varchar(20)
    )
    
    insert into @tempTb values('NoSpace'),('Have space'),('Two  space'),('With tab');
    
    select case when len(REPLACE(REPLACE([A],' ',''),char(9),''))<>len([A])
    then 'Error'
    else 'Success'
    end as HasSpaceOrTab
    from @tempTb

    Allen Li
    TechNet Community Support

    Friday, September 13, 2013 6:13 AM