Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6797877
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T18:39:46+00:00 2026-05-26T18:39:46+00:00

I have declare @a varchar(100) = ‘abc bcd cde def’ . What I need

  • 0

I have declare @a varchar(100) = 'abc bcd cde def'. What I need is to select from a table where a column is like ‘abc’ or ‘bcd’ or ‘cde’ or ‘def’. I can use a split function and a while to get what I want, but somewhere I saw a smart solution using replace or something similar and I just can’t remember it.

I know I can use an xml variable, and parse it that way. However, the value is part of a large procedure, and the best way for me is to use it in string form.

I know I can solve this by building a dynamic sql query, but that is not an option in the domain I’m working in.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T18:39:47+00:00Added an answer on May 26, 2026 at 6:39 pm

    Damn, I just can remember the solution. Its a hack, a little dirty trick that do the job.

    Anyways, I ll use the code bellow (Im over SQL Server 2008), is it a good idea? I prefer it over the dirty split. Is it more performatic?

    declare @w varchar(100) = 'some word'
    declare @f xml
    
    set @f = '<word>' + replace(@w, ' ', '</word><word>') + '</word>'
    
    select
        template.item.value('.', 'varchar(100)') as word
    from @f.nodes('/word') template(item)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this SQL DECLARE @url varchar(100) SET @url = 'http://mysite.com/%' SELECT [UserSessionSequenceID] ,[SiteID]
I have a sql function that includes this code: DECLARE @CodeNameString varchar(100) SELECT CodeName
I have the following table: DECLARE @TicketHolder TABLE ( [Name] VARCHAR(100), Tickets DECIMAL(18, 8)
I have a stored procedure DECLARE cursor FOR SELECT [FooData] From [FooTable]; OPEN cursor
I have a table with multiple words, from 1 to n. declare @words table
DECLARE @EmployeeList varchar(100) SELECT @EmployeeList = COALESCE(@EmployeeList + ', ', '') + CAST(Emp_UniqueID AS
I have created simple function create function TRIM(@data varchar(20)) returns varchar(100) as begin declare
I have a stored proc, say, call_Me with few parameters: Declare @Greet varchar(100) =
Consider this snippet: CREATE TABLE #Temp ( Name varchar(100) ) GO DECLARE @Name varchar(100)
Consider that I have a transaction: BEGIN TRANSACTION DECLARE MONEY @amount SELECT Amount AS

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.