Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Need help to search for extra space in all tables.

0 views
Skip to first unread message

LN

unread,
Aug 31, 2010, 1:08:03 PM8/31/10
to

I try to search for data which has some extra spaces in ALL TABLES.
Does any one know if there a tool that can do that or the scripts can return
all the data (see desire results below).
Thank you in advance. SQL2008.


IF OBJECT_ID('Tempdb.dbo.#T1', 'u') IS NOT NULL
DROP TABLE #T1
GO
CREATE TABLE #T1
(
FullName VARCHAR(30)
)
GO
INSERT INTO #T1 VALUES ('Joe Smith')
INSERT INTO #T1 VALUES ('April Smith ')
INSERT INTO #T1 VALUES ('Peter Chen')
INSERT INTO #T1 VALUES ('Kristine Nguyen')
GO


IF OBJECT_ID('Tempdb.dbo.#T2', 'u') IS NOT NULL
DROP TABLE #T2
GO
CREATE TABLE #T2
(
FullName VARCHAR(30)
)
GO
INSERT INTO #T2 VALUES (' John Smith')
INSERT INTO #T2 VALUES ('Lisa Tran ')
INSERT INTO #T2 VALUES ('Nicole Ngo')
INSERT INTO #T2 VALUES ('Brandon Lee')

GO

SELECT *
FROM #T1;
GO

SELECT *
FROM #T2;
GO

-- Desire results.

FullName TableName
---------------- ---------
Joe Smith #T1 (2 spaces in between)
April Smith #T1 (space after Smith)

John Smith #T2 (space in front)
Lisa Tran #T2 (space after Tran)
Nicole Ngo #T2 (2 spaces in between)

John Bell

unread,
Aug 31, 2010, 3:24:02 PM8/31/10
to
On Tue, 31 Aug 2010 10:08:03 -0700, LN <L...@discussions.microsoft.com>
wrote:


Not sure if this does all you want, look at the SearchAllTables
example on http://www.users.drew.edu/skass/sql/index.htm

John

0 new messages