Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

query problem?

Status
Not open for further replies.

nowayout

Programmer
Feb 25, 2003
364
US
insert into op_apps_daily.dbo.chktype values (select * from norway.dbo.chktype)
where norway.dbo.chktype.code not in (op_apps_daily.dbo.chktype)

i am getting error at select statement

what is wrong?
??
 
You don't use a values clause when the source of the data is a select statement. See SQL BOL for an explanation of Insert.

insert into op_apps_daily.dbo.chktype
select * from norway.dbo.chktype If you want to get the best answer for your question read faq183-874 and thread183-468158.
Terry L. Broadbent - DBA
SQL Server Page:
 
insert into op_apps_daily.dbo.chktype select * from norway.dbo.chktype
where norway.dbo.chktype.code not in (op_apps_daily.dbo.chktype)
 
The where clause will not work, either. You must use column names not table names. NOT Exists is better than NOT IN. NOT IN can return erroneous results.

Where NOT EXISTS
(Select * From op_apps_daily.dbo.chktype
Where keycol = norway.dbo.chktype.keycol)

If you want to get the best answer for your question read faq183-874 and thread183-468158.
Terry L. Broadbent - DBA
SQL Server Page:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top