Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Attach and detach a database programmatically
Message
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Autre
Divers
Thread ID:
01097394
Message ID:
01097395
Vues:
14
>I want to attach and detach a database in SQL SERVER 2000 programmatically with VFP 9 SP1.
>Is it possible?
>
>TIA
sqlh = SQLSTRINGCONNECT([Driver={SQL Server};Server=Boris;Trusted_Connection=yes;])
TEXT TO lcSql NOSHOW
     USE [master]
     CREATE DATABASE [Test] ON 
       ( FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\Test.mdf' ),
       ( FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\Test_log.ldf' )
     FOR ATTACH
ENDTEXT
TEXT TO lcSql2 NOSHOW
     if not exists (select name from master.sys.databases sd where name = N'Test' and SUSER_SNAME(sd.owner_sid) = SUSER_SNAME() ) EXEC [Test].dbo.sp_changedbowner @loginame=N'BORIS\Boris1', @map=false
ENDTEXT
? SQLEXEC(sqlh, lcSql)
? SQLEXEC(sqlh, lcSql2)
:-)

no error handling included
Against Stupidity the Gods themselves Contend in Vain - Johann Christoph Friedrich von Schiller
The only thing normal about database guys is their tables.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform