Showing posts with label identity_insert. Show all posts
Showing posts with label identity_insert. Show all posts

Monday, March 19, 2012

INSERT statement; only 1 column in table.. that too identity

need to write an insert statement to a table with only identity column
without using IDENTITY_INSERT option
create table t (id int identity(1,1) primary key)
RakeshRakesh
create table test(id int identity)
insert test default values
"Rakesh" <Rakesh@.discussions.microsoft.com> wrote in message
news:8DB21864-6422-485C-8D26-BCC16C261076@.microsoft.com...
> need to write an insert statement to a table with only identity column
> without using IDENTITY_INSERT option
> create table t (id int identity(1,1) primary key)
> Rakesh|||Thanx
"Uri Dimant" wrote:

> Rakesh
> create table test(id int identity)
> insert test default values
>
>
> "Rakesh" <Rakesh@.discussions.microsoft.com> wrote in message
> news:8DB21864-6422-485C-8D26-BCC16C261076@.microsoft.com...
>
>|||create table t (id int identity(1,1) primary key)
INSERT INTO t default values
Roji. P. Thomas
Net Asset Management
http://toponewithties.blogspot.com
"Rakesh" <Rakesh@.discussions.microsoft.com> wrote in message
news:8DB21864-6422-485C-8D26-BCC16C261076@.microsoft.com...
> need to write an insert statement to a table with only identity column
> without using IDENTITY_INSERT option
> create table t (id int identity(1,1) primary key)
> Rakesh

Friday, March 9, 2012

INSERT SELECT?

Hi all,
I am trying to run an INSERT SELECT statement. This should be an easy
query!!!
Code:
SET IDENTITY_INSERT asmt_v1_areas ON
INSERT INTO asmt_v1_areas ('asmt_v1_area_id','name','mid') SELECT
assmnt_area_id, name, mid FROM assmnt_areas
When i try to run this query i get an error message saying invalid object
name 'asmt_v1_areas'
This object does exists and i can issue select statements on it.
I assume i have some kind of syntax error.
Can someone enlighten me'
Cheers,
AdamAdam Knight,
Can you check the object's owner?. SQL Server is looking for the table
dbo.asmt_v1_areas. The table should have an identity column.
AMB
"Adam Knight" wrote:

> Hi all,
> I am trying to run an INSERT SELECT statement. This should be an easy
> query!!!
> Code:
> SET IDENTITY_INSERT asmt_v1_areas ON
> INSERT INTO asmt_v1_areas ('asmt_v1_area_id','name','mid') SELECT
> assmnt_area_id, name, mid FROM assmnt_areas
> When i try to run this query i get an error message saying invalid object
> name 'asmt_v1_areas'
> This object does exists and i can issue select statements on it.
> I assume i have some kind of syntax error.
> Can someone enlighten me'
> Cheers,
> Adam
>
>|||Don't use quotation marks around column names - instead of:
INSERT INTO asmt_v1_areas ('asmt_v1_area_id','name','mid')
use:
INSERT INTO asmt_v1_areas (asmt_v1_area_id, name, mid)
"Adam Knight" <dev@.brightidea.com.au> wrote in message
news:u6bzvfP2FHA.3788@.tk2msftngp13.phx.gbl...
> Hi all,
> I am trying to run an INSERT SELECT statement. This should be an easy
> query!!!
> Code:
> SET IDENTITY_INSERT asmt_v1_areas ON
> INSERT INTO asmt_v1_areas ('asmt_v1_area_id','name','mid') SELECT
> assmnt_area_id, name, mid FROM assmnt_areas
> When i try to run this query i get an error message saying invalid object
> name 'asmt_v1_areas'
> This object does exists and i can issue select statements on it.
> I assume i have some kind of syntax error.
> Can someone enlighten me'
> Cheers,
> Adam
>