Assign Tab delimit to variable in SQL Server


 Declare @tab char(1)
 set @tab=char(9)

 or

 Declare @tab nchar(1)
 set @tab=nchar(9)

 Now you can check tab space using @tab variable for example


 declare @str varchar(50)
 set @str='hai  how  are  you'
 declare @tab char(9)
 declare @len int 
 set @tab=char(9)
 set @len=len(@str)
 if ((@len-len(replace(@str,@tab,'')))>0)
 begin
  print 'Tab delimit is there'
 end
 else
 begin
  print 'Tab delimit is not there'
 end


Here the variable @str has string of 'hai how are you'. Now we find if the tab delimit is there or not, in above query if condition is checking whether tab delimit is there are not. If tab delimit is there, it will genearate a messge 'Tab delimit is there", otherwise it will generate a message 'Tab delimit is not there'.

Ebook Download
View all
Learn
View all