Jump to content


Popular Content

Showing content with the highest reputation on 11/04/2019 in all areas

  1. 1 point
    eu me deparei com este problema, e montei esta função que quebra os valores separados pela virgula: CREATE FUNCTION [dbo].[Z_SplitString] ( @sString nvarchar(2048) ) RETURNS @tParts TABLE ( part nvarchar(2048) ) --WITH ENCRYPTION AS BEGIN -- comment: sp_password DECLARE @cDelimiter nchar(1) SET @cDelimiter = ',' if @sString is null return declare @iStart int, @iPos int if substring( @sString, 1, 1 ) = @cDelimiter begin set @iStart = 2 insert into @tParts values( null ) end else set @iStart = 1 while 1=1 begin set @iPos = charindex( @cDelimiter, @sString, @iStart ) if @iPos = 0 set @iPos = len( @sString )+1 if @iPos - @iStart > 0 insert into @tParts values ( substring( @sString, @iStart, @iPos-@iStart )) else insert into @tParts values( null ) set @iStart = @iPos+1 if @iStart > len( @sString ) break end RETURN END GO para executar basta fazer assim: select * from tmov where codtmv in( SELECT part FROM Z_SplitString('1.2.06,1.2.09,1.2.13,1.2.15'))
This leaderboard is set to Sao Paulo/GMT-03:00
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.