JWColby
jwcolby at colbyconsulting.com
Wed Dec 6 15:35:10 CST 2006
Folks, Does anyone have a "something" in SQL Server that will take the name of a table, figure out all of the field names in the table, and return a data set with all of the data stripped of leading and trailing spaces? I have tables where the data waqs brought in to SQL Server from a fixed width file, padded right (mostly) with spaces. Thus the data is represented inside the table as fixed width with spaces to the right of any real data. I need to get the data out, strip the spaces (both leading and trailing) and the write that data back into the same or another table, doesn't matter which to me. I know how to do this by creating a view and then use "ltrim(rtrim(data)) as SomeFieldName" kind of a thing but that means a custom view for each table, manually edited to create these "ltrim(rtrim(" constructs. I assume if I knew how to do udfs or stored procedures that you could go get the field names of the fields and dynamically build a sql string. Has anyone seen such a thing? John W. Colby Colby Consulting www.ColbyConsulting.com