Re: Identity_Insert
- From: "Richard Mueller" <rlmueller-NOSPAM@xxxxxxxxxxxxxxxxxxxx>
- Date: Tue, 3 Jan 2006 17:38:23 -0600
Herb wrote:
> I'm trying to set Identity_Insert for a SQL Server table using VB code via
> an
> ADO connection but it doesn't seem to be working.
>
> According to the SQL Server 2000 books online you can have only one table
> in
> a database set with this value, at any one time. I've proved this using
> query
> analyzer and setting ON for table1 and then my attempt to set ON for
> table2
> fails telling me that table is already set.
>
> However, If I leave the setting on for table1 and then execute the
> following
> code behind an MSAccess form:
>
> Const TargetConnectionString = "Provider=SQLOLEDB.1;Initial
> Catalog=BookkeeperSource;Data Source=PTLPSRV02;Integrated Security=SSPI;
> Persist Security Info=False;"
>
> Dim cmd As New ADODB.Command
> cmd.CommandText = "SET IDENTITY_INSERT BookkeeperSource.dbo.table1 OFF"
> cmd.ActiveConnection = TargetConnectionString
> cmd.Execute
> cmd.ActiveConnection.Close
>
> I do not get an error out of this code but when I attempt to set
> identity_insert on for table2 in query analyzer, I get the message saying
> that identity_insert is already on for table1.
>
> Am I wrong to think that the code executed behind the form should have
> removed that setting for table1?
>
> Thanks in advance for any help you can shed on this.
Hi,
I've done almost exactly the same thing with SQL Server databases with no
problems. It's as if your code did not run. Can you somehow verify that the
code ran, perhaps displaying a message at the end?
--
Richard
Microsoft MVP Scripting and ADSI
Hilltop Lab - http://www.rlmueller.net
.
- Prev by Date: Re: WriteXML
- Next by Date: Re: how to reference feild data -
- Previous by thread: Re: WriteXML
- Next by thread: RE: Using Rich Text formating with InfoPath
- Index(es):
Relevant Pages
- Re: Proposal: 6NF
... Should I try it on Sybase ASE 12.5? ... SQL SERVER, ORACLE and DB2 have
the same heritage then... ... insert table1 ... consequence of allowing NULLS
at the first place... ... (comp.databases.theory) - Re: HOWTO: Use conditions in FROM clause in Access sintax.
... If you execute them in SQL Server I ... and that means that I need all
rows in Table1 and only matching one in ... >> Table2 Ref RefExt RefTwo Data
... (microsoft.public.access.queries) - Re: HOWTO: Use conditions in FROM clause in Access sintax.
... If you execute them in SQL Server I ... Table1 Ref ... This is
the result I get in SQL Server if I execute that query. ... FROM (Q_Table2 INNER JOIN
Table1 ON Q_Table2.Ref = Table1.Ref) ... (microsoft.public.access.queries) - Re: VFP 9/SQL Server Integration Question
... You can do it in VFP6 too! ... file entry on Remote Views. ...
> but I want to move the databases to SQL Server. ... > statement "USE TABLE1"
to use the table, can I create a SQL table ... (microsoft.public.fox.helpwanted) - How to increment record id in an insert stored procedure
... Within SQL server there is a facility to have ... I need to insert records from
table2 ... to table1. ... >Commit Transaction ... (microsoft.public.sqlserver.programming)