• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 249
  • Last Modified:

scan all the columns if first char is space

is there a way to loop through the data of a table - for each string column and see if the first character of the string field is a space?
2 Solutions
Aneesh RetnakaranDatabase AdministratorCommented:
this will generate the necessay sql, you can copy the results and run it

select 'select * from '+table_name +' where '+column_name +' like '' %''  ' from information_schema.columns  where table_name = 'yourTableName'
and data_type like '%char%'
Anthony PerkinsCommented:
It would be a lot faster to spell out all the string columns in a query then resort to building a complex query using Dynamic SQL to do the same.  In other words if you can take the time to write this out it would be faster and less error prone:

FROM YourTableName
WHERE YourStringCol1 LIKE ' %'
             OR YourStringCol2 LIKE ' %'
             OR YourStringCol3 LIKE ' %'
             OR ...

25112Author Commented:

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now