Index
2018-09-06 09:27Rafael Copquin : alter column in sql server
2018-09-06 09:34Ted Roche : Re: alter column in sql server
2018-09-06 09:42Stephen Russell : Re: alter column in sql server
2018-09-06 10:01Vince Teachout : Re: alter column in sql server
2018-09-06 10:02Vince Teachout : Re: alter column in sql server
2018-09-06 10:03Kevin J Cully : RE: alter column in sql server
2018-09-06 13:40Rafael Copquin : Re: alter column in sql server
2018-09-12 08:38Richard Kaye : RE: alter column in sql server
Back to top
alter column in sql server

Author: Rafael Copquin

Posted: 2018-09-06 09:27:53   Link

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: ProFox@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+VmOUw@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.

©2018 Rafael Copquin
Back to top
Re: alter column in sql server

Author: Ted Roche

Posted: 2018-09-06 09:34:26   Link

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.

On Thu, Sep 6, 2018 at 10:28 AM Rafael Copquin <rafael.copquin@gmail.com>

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: ProFox@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-8zw_C2swCV5pt2KMoJpQ@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.

©2018 Ted Roche
Back to top
Re: alter column in sql server

Author: Stephen Russell

Posted: 2018-09-06 09:42:48   Link

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 <rafael.copquin@gmail.com>

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: ProFox@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+tvfgbPj5cgS7qunUCa0Cew@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.

©2018 Stephen Russell
Back to top
Re: alter column in sql server

Author: Vince Teachout

Posted: 2018-09-06 10:01:56   Link

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: ProFox@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-389d3c254549@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 see the obvious.

©2018 Vince Teachout
Back to top
Re: alter column in sql server

Author: Vince Teachout

Posted: 2018-09-06 10:02:26   Link

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: ProFox@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-11e45ef93d87@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 see the obvious.

©2018 Vince Teachout
Back to top
RE: alter column in sql server

Author: Kevin J Cully

Posted: 2018-09-06 10:03:07   Link

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-bounces@leafe.com] On Behalf Of Ted Roche

Sent: Thursday, September 06, 2018 10:34 AM

To: profox@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.

On Thu, Sep 6, 2018 at 10:28 AM Rafael Copquin <rafael.copquin@gmail.com>

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: ProFox@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/SN6PR0901MB2526D38678CDAB0BF8ABD3DBC5010@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.

©2018 Kevin J Cully
Back to top
Re: alter column in sql server

Author: Rafael Copquin

Posted: 2018-09-06 13:40:32   Link

Thank you Kevin

Rafael

El jue., 6 sept. 2018 a las 12:03, Kevin J Cully (<kjcully@cherokeega.com>)

escribió:

> 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-bounces@leafe.com] On Behalf Of Ted Roche

> Sent: Thursday, September 06, 2018 10:34 AM

> To: profox@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.

>

> On Thu, Sep 6, 2018 at 10:28 AM Rafael Copquin <rafael.copquin@gmail.com>

> 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: ProFox@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-bcWjbMDwBHyJ0hw@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.

©2018 Rafael Copquin
Back to top
RE: alter column in sql server

Author: Richard Kaye

Posted: 2018-09-12 08:38:50   Link

For all you Thor users out there, check out the Super Browse tool.

--

rk

-----Original Message-----

From: ProfoxTech <profoxtech-bounces@leafe.com> On Behalf Of Vince Teachout

Sent: Thursday, September 6, 2018 11:02 AM

To: profoxtech@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: ProFox@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/BN6PR10MB12998E9B7DD26A9491F3BE21D21B0@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 obvious.

©2018 Richard Kaye