1
2
|
--查找数据库中哪些表拥有指定的列名
select
OBJECT_NAME(id)
from
syscolumns
where
name
=
'ColumnName'
|
2.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
--查找表中是否有完全重复的数据
DECLARE
@allCount
INT
DECLARE
@disCount
INT
SET
@allCount = (
SELECT
COUNT
(*)
AS
allCount
FROM
table
)
SELECT
DISTINCT
*
INTO
#
temp
FROM
table
SET
@disCount = (
SELECT
COUNT
(*)
AS
disCount
FROM
#
temp
)
DROP
TABLE
#
temp
IF(@allCount-@disCount>0)
BEGIN
PRINT
'Have complete same rows'
END
ELSE
BEGIN
PRINT
'No complete same rows'
END
|
3.
1
2
3
4
5
|
--判断某表是否存在
if object_id(
'tableName'
)
IS
NOT
null
BEGIN
--do what you want
END
|