search n raiseerror

  • one

    table has one coulmn and one row only.that row is a text

    i need

    to find one particular word in that row. say word ='db_proc_exec'

    if

    its there then ok

    if

    that word is not there then raise error.

    how

    to do this?

  • It doesn't seem like you can use RAISERROR in a SELECT statement (though BOL doesn't say anything about it). Unless there is any constraint of doing it in one single statement, I would take the count in a variable and if it's 0 then I would raise an error. Something like:

    declare @test-2 table(id int, descr varchar(50))

    declare @exists int

    insert into @test-2 values (1, 'testing')

    select @exists = count(*) from @test-2 where descr like '%pest%'

    if @exists = 0

    RAISERROR('Doesn''t exist',10,1,null, null)

    For more information on RAISERROR you can look here.

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply