Discussion:
alter column in sql server
Rafael Copquin
2018-09-06 14:27:53 UTC
Permalink
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
---

_______________________________________________
Post Messages to: ***@leafe.com
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/CAHM-jJ2=YiH4U9okG8kR=CCYYmgkeeRXhftmc6eZzREJ+***@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.
Ted Roche
2018-09-06 14:34:26 UTC
Permalink
Why not write the script in VFP and then cut-and-paste it into the SQL
Server? Use AFIELDS to get the fieldlist, TEXTMERGE to write the script.
Easy, peasy.
Post by Rafael Copquin
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: ***@leafe.com
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/CACW6n4s_=3gd8QAa-gpOXzc07pMej-***@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.
Kevin J Cully
2018-09-06 15:03:07 UTC
Permalink
Take a look in the Downloads area for the Stru2PostgreSQL and Stru2MySQL_2 program. It should be pretty easy to modify those to get the structures generated.

http://leafe.com/download/stru2postgreSQL.PRG
http://leafe.com/download/stru2mysql_2.prg

-Kevin


-----Original Message-----
From: ProFox [mailto:profox-***@leafe.com] On Behalf Of Ted Roche
Sent: Thursday, September 06, 2018 10:34 AM
To: ***@leafe.com
Subject: Re: alter column in sql server

Why not write the script in VFP and then cut-and-paste it into the SQL Server? Use AFIELDS to get the fieldlist, TEXTMERGE to write the script.
Easy, peasy.
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: ***@leafe.com
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/***@SN6PR0901MB2526.namprd09.prod.outlook.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.
Rafael Copquin
2018-09-06 18:40:32 UTC
Permalink
Thank you Kevin
Rafael
Post by Kevin J Cully
Take a look in the Downloads area for the Stru2PostgreSQL and Stru2MySQL_2
program. It should be pretty easy to modify those to get the structures
generated.
http://leafe.com/download/stru2postgreSQL.PRG
http://leafe.com/download/stru2mysql_2.prg
-Kevin
-----Original Message-----
Sent: Thursday, September 06, 2018 10:34 AM
Subject: Re: alter column in sql server
Why not write the script in VFP and then cut-and-paste it into the SQL
Server? Use AFIELDS to get the fieldlist, TEXTMERGE to write the script.
Easy, peasy.
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: ***@leafe.com
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/CAHM-jJ0Ezush43qhQUtfh9nuyuepUkqvHR-***@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 th
Stephen Russell
2018-09-06 14:42:48 UTC
Permalink
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
Post by Rafael Copquin
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: ***@leafe.com
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+***@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.
Vince Teachout
2018-09-06 15:01:56 UTC
Permalink
I wrote a little function that reads in a vfp table, and outputs a SQL
Create table script.  Would be super simple to either alter it to output
Substr(coriginalname,3) or to edit/replace the field names in the text
output file.  Do you want it?

---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus



_______________________________________________
Post Messages to: ***@leafe.com
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/780612c1-60c2-22f9-c47f-***@caracal.net
** 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 s
Vince Teachout
2018-09-06 15:02:26 UTC
Permalink
I wrote a little function that reads in a vfp table, and outputs a SQL
Create table script.  Would be super simple to either alter it to output
Substr(coriginalname,3) or to edit/replace the field names in the text
output file.  Do you want it?

---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus


_______________________________________________
Post Messages to: ***@leafe.com
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/550d1270-2b3a-ab2f-4745-***@taconic.net
** 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 se
Richard Kaye
2018-09-12 13:38:50 UTC
Permalink
For all you Thor users out there, check out the Super Browse tool.
--
rk

-----Original Message-----
From: ProfoxTech <profoxtech-***@leafe.com> On Behalf Of Vince Teachout
Sent: Thursday, September 6, 2018 11:02 AM
To: ***@leafe.com
Subject: Re: alter column in sql server

I wrote a little function that reads in a vfp table, and outputs a SQL Create table script.  Would be super simple to either alter it to output
Substr(coriginalname,3) or to edit/replace the field names in the text output file.  Do you want it?

---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus


_______________________________________________
Post Messages to: ***@leafe.com
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/***@BN6PR10MB1299.namprd10.prod.outlook.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
Loading...