Hi, I just want to know to turn this:
CREATE TABLE [dbo].[tblTierCs] (
[idTierC] [int] NOT NULL ,
[txtNoEmploye] [varchar] (50) COLLATE French_CI_AS NULL ,
[noSubDomain] [int] NOT NULL ,
[txtNameTierC] [varchar] (50) COLLATE French_CI_AS NOT NULL ,
[noOldTierC] [int] NULL ,
[noRSDTierC] [int] NULL
) ON [PRIMARY]
into this:
CREATE TABLE [dbo].[tblTierCs] (
[idTierC] [int] IDENTITY (1, 1) NOT NULL ,
[txtNoEmploye] [varchar] (50) COLLATE French_CI_AS NULL ,
[noSubDomain] [int] NOT NULL ,
[txtNameTierC] [varchar] (50) COLLATE French_CI_AS NOT NULL ,
[noOldTierC] [int] NULL ,
[noRSDTierC] [int] NULL
) ON [PRIMARY]
using an ALTER TABLE query. I tried using:
ALTER TABLE [dbo].[tblTierCs] ALTER COLUMN [idTierC] [int] IDENTITY
(1, 1) NOT NULL but it's not working. Anyone has any idea how I could
do it? Thanks. 2 44296
Heist (ad************ *****@hotmail.c om) writes: Hi, I just want to know to turn this: CREATE TABLE [dbo].[tblTierCs] ( [idTierC] [int] NOT NULL , [txtNoEmploye] [varchar] (50) COLLATE French_CI_AS NULL , [noSubDomain] [int] NOT NULL , [txtNameTierC] [varchar] (50) COLLATE French_CI_AS NOT NULL , [noOldTierC] [int] NULL , [noRSDTierC] [int] NULL ) ON [PRIMARY] into this: CREATE TABLE [dbo].[tblTierCs] ( [idTierC] [int] IDENTITY (1, 1) NOT NULL , [txtNoEmploye] [varchar] (50) COLLATE French_CI_AS NULL , [noSubDomain] [int] NOT NULL , [txtNameTierC] [varchar] (50) COLLATE French_CI_AS NOT NULL , [noOldTierC] [int] NULL , [noRSDTierC] [int] NULL ) ON [PRIMARY]
using an ALTER TABLE query. I tried using: ALTER TABLE [dbo].[tblTierCs] ALTER COLUMN [idTierC] [int] IDENTITY (1, 1) NOT NULL but it's not working. Anyone has any idea how I could do it? Thanks.
You cannot use ALTER TABLE to change a column into IDENTITY column
(except on SQL Server CE!). One way is to rename the table, create
a new and move over the data. You need to have SET IDENTITY_INSERT
on for the table when you move the data.
You can also do it in Enterprise Mangager - which will renamed and
move data behind the scenes.
--
Erland Sommarskog, SQL Server MVP, so****@algonet. se
Books Online for SQL Server SP3 at http://www.microsoft.com/sql/techinf...2000/books.asp
What I ended up doing is using SQL Server Entreprise Manager to
"manually" alter the table and then I used the script generator to
create a script I could then used. Thanks. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Bruce |
last post by:
Hi,
I want to change the datatype of an existing column from char to
varbinary. When I run the "Alter Table" statement, I get the
following error message -
Disallowed implicit conversion from data type char to data type
varbinary, table 'test.dbo.testalter', column 'col1'. Use the CONVERT
function to run this query.
|
by: Jon Combe |
last post by:
I have created the following test SQL code to illustrate a real
problem I have with some SQL code.
CREATE TABLE JCTable ( CustomerName varchar(50) )
ALTER TABLE JCTable ADD CustomerNo int
INSERT INTO JCTable ( CustomerName , CustomerNo ) VALUES ( 'Jon Combe'
, 1 )
INSERT INTO JCTable ( CustomerName , CustomerNo ) VALUES ( 'Bill
Gates' , 1 )
UPDATE JCTable SET CustomerNo = 2 WHERE CustomerName = 'Jon Combe'
|
by: boonkit |
last post by:
I try to get better performance by implementing this:
http://dev.mysql.com/doc/mysql/en/alter-table.html
"ORDER BY allows you to create the new table with the rows in a
specific order. Note that the table does not remain in this order after
inserts and deletes. This option is mainly useful when you know that
you are mostly going to query the rows in a certain order; by using
this option after big changes to the table, you might be able...
|
by: pb648174 |
last post by:
I am trying to add a column to a temp table and then immeditaely query
against that new column. If I do this in Query Analyzer it works fine
as long as there is a go in between, but I can't use a go inside a
stored proc.. How do i get SQL to finish processing the alter table
command so I can use the new column?
alter table #TempPaging add TIId int not null identity
--go --fixes the problem in QA, but not in proc
Select * From...
|
by: Gianfranco |
last post by:
Hi, I'm not familiar at access and at VBA either, so I need some help
or at least some hint please.
I have table "availabledrivers", coming from a query to the table
"drivers". Then I have a table "availablebus" coming from a query to
"bus".
Bus and Drivers have autonumber ID, so the tables I get have the IDs
screwed up..I mean..there are "holes" in them..it's like 1,2,5,7,11,20
etc
Now..I need to link the 2 resulting table...and I have...
| |
by: Jeff_in_MD |
last post by:
Hi,
I'm trying to add a column to a table, then update that column with a
query. This is all within a single batch. Sqlcmd gives me an error on
the update, saying "invalid column xxx", because it doesn't know the
column got added. We used to get around this in "osql" by using the
EXECUTE command, like: EXEC ("ALTER TABLE tbl ADD newfield varchar(255)
not null default ' '")
However, it looks like sqlcmd actually checks each query...
|
by: JenavaS |
last post by:
I am trying to create a macro to change a data type in a column. The table was created using a "make-table" query, and the column(s) I want to modify were created using a calculation in my query. Therefore, the data in the column has a lot of numbers after the decimal.
I could go into the table's design view and change the decimals from Auto to 2, and the format to Percent, however I would like this to happen automatically after the...
|
by: quincy451 |
last post by:
drop table .
CREATE TABLE . (
NULL ,
(16) COLLATE SQL_Latin1_General_CP1_CI_AS
NULL ,
NULL ,
NULL ,
(16) COLLATE SQL_Latin1_General_CP1_CI_AS
NULL ,
(16) COLLATE
|
by: Chris |
last post by:
Hi,
I am trying to run the following SQL through the DB2 command line for
version 9.1.0:
alter table SCHEMA.TABLE1
drop column A;
alter table SCHEMA.TABLE2
alter column B set data type decimal(15,4);
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |