Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7856501
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T20:44:00+00:00 2026-06-02T20:44:00+00:00

I have a database on my student server, I need to go to my

  • 0

I have a database on my student server, I need to go to my university if I want to access the database properties using the SQL server DBMS, it is a pain. I want to know if I can change the identity specification by using SQL on a specific table? I cannot insert to a table as this is not selected to yes, I want to be able to make these changes from home can I do this?

I was researching how to access tables and change some properties, and came across something like this:

Set IDENTITY_INSERT TableName ON

I want to be able to do this using a php script and some SQL, like this:

$query = "IDENTITY_INSERT customers ON ";

        $result = sqlsrv_query( $conn, $query, array(), array( "Scrollable" => SQLSRV_CURSOR_KEYSET ));

        if( $result === false)
        {
            echo "Error in query preparation/execution.\n";
            die( print_r( sqlsrv_errors(), true));
        }

        else
        {
            echo'worked';
        }

will this work?

Here is my rough attempt at doing this:

<?php
$serverName = "servername";
    $connectionInfo = array("UID" => "username", "PWD" => "password",      "Database"=>"database");
    $conn = sqlsrv_connect( $serverName, $connectionInfo);

    if( $conn === false ) // note the format of ‘equals’
    {
         echo "Could not connect.\n";
         die( print_r( sqlsrv_errors(), true));
    }



        $query = "SET IDENTITY_INSERT customers ON ";

        $result = sqlsrv_query( $conn, $query, array(), array( "Scrollable" => SQLSRV_CURSOR_KEYSET ));

        if( $result === false)
        {
            echo "Error in query preparation/execution.\n";
            die( print_r( sqlsrv_errors(), true));
        }

        else
        {
            echo'worked';
        }

?>

Thank you.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T20:44:01+00:00Added an answer on June 2, 2026 at 8:44 pm

    IDENTITY_INSERT is the correct syntax, although you appear to have missed off the SET keyword in your usage. See this line:

    $query = "IDENTITY_INSERT customers ON ";
    

    Change to:

     $query = "SET IDENTITY_INSERT customers ON ";
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have 3 tables in my SQL Server database: Teacher Student Parent Each of
i want to get data from sql server database in asp.net using NHibernate. what
I am using SQL Server 2008, and in my database I have a table
I need to export data from a SQL database (some groups use SQL Server,
I have a table named t_Student in Microsoft SQL Server 2005 database. In that
I need help writing a MySQL trigger. Suppose you have a student database with
We have an old Access 2000 database that we need to pull data from
I have a simple application which stores the data into the sql server database
I have a database Student which contains about 20 tables. one of the tables
I have a database table named 'student' in which there is one column named

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.