SQL2000中如何查询字段名?

来源:百度知道 编辑:UC知道 时间:2024/05/10 08:24:20
我要在数据库中插入一个新的表名ABC,想先查询下数据库里面有没有存在这个表名,用SQL语句怎么写啊?在线等!急啊!

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[abc]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)

搞错了!不好意思!我重写!

这是我以前写的一个!
你可以试试看:

create procedure here @add_row varchar(5)

AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.

-- Insert statements for procedure here
if @add_row is null
print '输入列名'
else
if
(select count(*) from information_schema.columns where table_name = 'student' and column_name=@add_row)>'0'
print '已存在'
else
exec ('alter table student add '+@add_row+' char(10)')
END
GO