0

I have a sql string that i would like to execute it in SQL Server 2000

Example:

DECLARE @CodeNameString VARCHAR(1000)
SET @CodeNameString = '%123% OR name LIKE %456% OR name LIKE %789%'
SELECT * FROM atable WHERE name LIKE @CodeNameString

Of course the above would be a lot easier in SQL 2008 but unfortunately i don't have that option...:

SET @CodeNameString = '"123" OR "456" OR "789"'
SELECT * FROM atable WHERE CONTAINS(name, @CodeNameString)

Is that possible?

1 Answer 1

1

I believe Sql 2000 also had dynamic Sql capabilities, in which case you can execute the whole query dynamically :

EXEC(N'SELECT * FROM atable WHERE name LIKE ''%123%'' 
       OR name LIKE ''%456%'' OR name LIKE ''%789%''')
Sign up to request clarification or add additional context in comments.

1 Comment

N indicates that the string following is a Unicode literal e.g. NVARCHAR

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.