Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Development Tools
 ASP.NET
 Inserterting the same rows with different id

Author  Topic 

Swati Jain
Posting Yak Master

139 Posts

Posted - 2007-12-18 : 01:41:33
Is there any query which copies the rows of the table and insert into same table with different id value?

insert into ReportDetails(ReportID,
Label,
TableName,
FieldNameID,
FieldName,
DisplayTableName,
DisplayFieldName,
DisplayType,
FieldDataType,
FieldOrder,
UpdateDate,
CreateDate ) values (Select ReportID,Label,TableName,FieldNameID,FieldName,DisplayTableName,DisplayFieldName,DisplayType,FieldDataType,FieldOrder,UpdateDate,CreateDate from ReportDetails Where ReportID=100)
This is not working bcoz i get error at brackets of Select

chiragkhabaria
Master Smack Fu Yak Hacker

1907 Posts

Posted - 2007-12-18 : 02:16:49
You dont require values when you are using Select Clause for inserting the values.


insert into ReportDetails(ReportID,
Label,
TableName,
FieldNameID,
FieldName,
DisplayTableName,
DisplayFieldName,
DisplayType,
FieldDataType,
FieldOrder,
UpdateDate,
CreateDate )
Select ReportID,Label,TableName,FieldNameID,FieldName,DisplayTableName,DisplayFieldName,DisplayType,FieldDataType,FieldOrder,UpdateDate,CreateDate from ReportDetails Where ReportID=100


Chirag

http://www.chirikworld.com
Go to Top of Page

Swati Jain
Posting Yak Master

139 Posts

Posted - 2007-12-18 : 02:20:10
quote:
Originally posted by chiragkhabaria

You dont require values when you are using Select Clause for inserting the values.


insert into ReportDetails(ReportID,
Label,
TableName,
FieldNameID,
FieldName,
DisplayTableName,
DisplayFieldName,
DisplayType,
FieldDataType,
FieldOrder,
UpdateDate,
CreateDate )
Select ReportID,Label,TableName,FieldNameID,FieldName,DisplayTableName,DisplayFieldName,DisplayType,FieldDataType,FieldOrder,UpdateDate,CreateDate from ReportDetails Where ReportID=100


Chirag

http://www.chirikworld.com



Hi Chirag,

Removing brackets also doesnt work
Go to Top of Page

chiragkhabaria
Master Smack Fu Yak Hacker

1907 Posts

Posted - 2007-12-18 : 02:22:59
[code]

Insert ReportDetails(ReportID,
Label,
TableName,
FieldNameID,
FieldName,
DisplayTableName,
DisplayFieldName,
DisplayType,
FieldDataType,
FieldOrder,
UpdateDate,
CreateDate )
Select ReportID,Label,TableName,FieldNameID,FieldName,DisplayTableName,
DisplayFieldName,DisplayType,FieldDataType,FieldOrder,UpdateDate,CreateDate from ReportDetails Where ReportID=100



[/code]

Chirag

http://www.chirikworld.com
Go to Top of Page

mahesh_bote
Constraint Violating Yak Guru

298 Posts

Posted - 2007-12-18 : 02:24:23
is it throwing any error? 1st try to execute the select statement separately and check whether the select is returning any record(s).

thanks,

Mahesh
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2007-12-18 : 03:26:48
quote:
Originally posted by Swati Jain

quote:
Originally posted by chiragkhabaria

You dont require values when you are using Select Clause for inserting the values.


insert into ReportDetails(ReportID,
Label,
TableName,
FieldNameID,
FieldName,
DisplayTableName,
DisplayFieldName,
DisplayType,
FieldDataType,
FieldOrder,
UpdateDate,
CreateDate )
Select ReportID,Label,TableName,FieldNameID,FieldName,DisplayTableName,DisplayFieldName,DisplayType,FieldDataType,FieldOrder,UpdateDate,CreateDate from ReportDetails Where ReportID=100


Chirag

http://www.chirikworld.com



Hi Chirag,

Removing brackets also doesnt work


What was the error message you got?

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

Swati Jain
Posting Yak Master

139 Posts

Posted - 2007-12-18 : 09:05:15
Problem got solved. Only bcoz of 'values' error was thrown
Go to Top of Page
   

- Advertisement -