I made a simple table,st_ex, with ST.... columns and then here is the change script to strip the ST off: /* To prevent any potential data loss issues, you should review this script in detail before running it outside the context of the database designer.*/ BEGIN TRANSACTION SET QUOTED_IDENTIFIER ON SET ARITHABORT ON SET NUMERIC_ROUNDABORT OFF SET CONCAT_NULL_YIELDS_NULL ON SET ANSI_NULLS ON SET ANSI_PADDING ON SET ANSI_WARNINGS ON COMMIT BEGIN TRANSACTION GO EXECUTE sp_rename N'dbo.st_ex.STID', N'Tmp_ID', 'COLUMN' GO EXECUTE sp_rename N'dbo.st_ex.STNAME', N'Tmp_Name_1', 'COLUMN' GO EXECUTE sp_rename N'dbo.st_ex.STAddress1', N'Tmp_ADDRESS1_2', 'COLUMN' GO EXECUTE sp_rename N'dbo.st_ex.Tmp_ID', N'ID', 'COLUMN' GO EXECUTE sp_rename N'dbo.st_ex.Tmp_Name_1', N'Name', 'COLUMN' GO EXECUTE sp_rename N'dbo.st_ex.Tmp_ADDRESS1_2', N'ADDRESS1', 'COLUMN' GO ALTER TABLE dbo.st_ex SET (LOCK_ESCALATION = TABLE) GO COMMIT
On Thu, Sep 6, 2018 at 9:28 AM Rafael Copquin <[email protected]> wrote: > I need to import a DBF table into SQL Server > However, all the fields in the DBF table begin with the suffix ST (a > previous programmer built the table in 1992, with the notion that all > fields should have a specific suffix related to the table's purpose) > > But I just want the sql server table to have all its fields without that > suffix, ie: STACCT should become ACCT, STNAME should become NAME and so on, > > The DBF table has 60 fields. > > I would like to issue an ALTER TABLE statement directly in the SQL Server > Management Studio to remove the ST suffix from all its fields. > > But I have no idea on how to build a stored procedure with something > similar to a DO WHILE loop in SQL Server, such that it would read a field > name, remove the ST suffix and alter the name as desired. And then pass to > the next field and do the same > > In fact, I must do the same with all the DBF tables from the old DOS > system, because I am converting it to a VFP9 app with a SQL Server back > end. > > Please show me a code snippet that would do that > > Thank you in advance > > Rafael Copquin > > > --- StripMime Report -- processed MIME parts --- > multipart/alternative > text/plain (text body -- kept) > text/html > --- > [excessive quoting removed by server] _______________________________________________ Post Messages to: [email protected] Subscription Maintenance: http://mail.leafe.com/mailman/listinfo/profox OT-free version of this list: http://mail.leafe.com/mailman/listinfo/profoxtech Searchable Archive: http://leafe.com/archives/search/profox This message: http://leafe.com/archives/byMID/profox/CAJidMY+qv=an-bceiyh6sbcvbec+tvfgbpj5cgs7qunuca0...@mail.gmail.com ** All postings, unless explicitly stated otherwise, are the opinions of the author, and do not constitute legal or medical advice. This statement is added to the messages for those lawyers who are too stupid to see the obvious.

