Re: How to know if a table exist in a Stored Procedure?



Thanks Arnie!

--
Jorge L. Cotarelo

"Arnie Rowland" <arnie@xxxxxxxx> escribió en el mensaje news:OuvRvu10GHA.4448@xxxxxxxxxxxxxxxxxxxxxxx
Of course, if you wanted to avoid accessing the system tables, and create code that will still work in future versions (when syscomments is no longer available), try something like this:

SELECT TABLE_NAME
FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_NAME = 'MyTable'

(But then again, contrary to Microsoft's assertions, the INFORMATION_SCHEMA views may not be around in the future. But we have been warned about using the system tables.)

--
Arnie Rowland, Ph.D.
Westwood Consulting, Inc

Most good judgment comes from experience.
Most experience comes from bad judgment.
- Anonymous


"Hari Prasad" <hari_prasad_k@xxxxxxxxxxx> wrote in message news:uhJ87V00GHA.4972@xxxxxxxxxxxxxxxxxxxxxxx
> Hi,
>
> use dbname
> go
> Select object_name(id) from syscomments where text like '%table_name%'
>
> Replace table_name with actual table name.
>
> Thanks
> Hari
> SQL Server MVP
>
>
> "Grupo ESI" <Pedir@xxxxxxxxxxxxxxx> wrote in message
> news:eRsvJT00GHA.720@xxxxxxxxxxxxxxxxxxxxxxx
>> Hi,
>>
>> Can anybody please tell me How to know if a table exist in a Stored
>> Procedure?
>>
>> Thanks in advance,
>>
>> --
>> Jorge L. Cotarelo

Relevant Pages


Loading