is it possible to apply is Null and Trim in all columns of table

hi,

i have table with 150  columns .i need to apply isnull and trim in all columns .is there any common function available to apply table level

kumarjcetAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

for_yanCommented:
Please, elaborate a little bit - what are you doing specifically - do yout read resultSet with JDBC - in what suituation are you using these
isNull() and trim() - do you mean java methods or something ion SQL side?

Please, be a little bit more claer on this.
0
Evan CutlerVolunteer Chief Information OfficerCommented:
Hi...
For the TRIM function:
Run this script:
DECLARE @SQL VARCHAR(MAX) DECLARE @TableName NVARCHAR(128) SET @TableName = 'YourTableName'  SELECT @SQL = COALESCE(@SQL + ',[', '[') +                COLUMN_NAME + ']=RTRIM([' + COLUMN_NAME + '])' FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = @TableName     AND DATA_TYPE = 'varchar'  SET @SQL = 'UPDATE [' + @TableName + '] SET ' + @SQL PRINT @SQL

The output of this script will give you the script to run your trims.
Copy and paste the output back into your workspace and run the output as a sql statement.
All of your columns should be trimmed.

Can I get more info on isnull?
0
Evan CutlerVolunteer Chief Information OfficerCommented:
sorry, replace 'YourTableName' with the table you are running this on.
0
10 Tips to Protect Your Business from Ransomware

Did you know that ransomware is the most widespread, destructive malware in the world today? It accounts for 39% of all security breaches, with ransomware gangsters projected to make $11.5B in profits from online extortion by 2019.

kumarjcetAuthor Commented:
hi i am getting data from some other database its returning for most aof the columns null and and its having some spaces....

i have the same table with my end sql server.i need to check whether that record is already exist or not if exist no need to insert while comparing my table with remote table having some NULL values in column and spaces..while comparing it will show different so it will insert new record ..i need to avoid that

each table having 150 columns
0
Evan CutlerVolunteer Chief Information OfficerCommented:
so you are saying some of the source tables will have spaces, and you have nulls, or the reverse? and it will assume that space != nulls, and try to insert another record as a new one?

Who's got spaces, and who's got nulls?
0
Evan CutlerVolunteer Chief Information OfficerCommented:
Just a side note, this sounds awefully like an ETL job.
Have you considered an ETL process to upload your data at regular intervals.  
Some of the new ETL tools are open source (meaning free), and have UI functions
to counterman these  issues.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
kumarjcetAuthor Commented:
hi arcee123 :...its a batchjob work it will run every 30 min  and pull data from some remote database ...

0
Evan CutlerVolunteer Chief Information OfficerCommented:
ok...so...who's got spaces, adn who's got nulls?
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java EE

From novice to tech pro — start learning today.