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
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Insert into

Author  Topic 

sardinka
Posting Yak Master

142 Posts

Posted - 2005-08-11 : 15:06:40
2 Questions about this SQl:
insert into rules
(RuleText)
values (select RuleText from temp_groupRules )
1. I am getting this errors:
Server: Msg 156, Level 15, State 1, Line 2
Incorrect syntax near the keyword 'select'.
Server: Msg 170, Level 15, State 1, Line 2
Line 2: Incorrect syntax near ')'.
2.My select statement may return 2 or more records. How do I handle this?

AjarnMark
SQL Slashing Gunting Master

3246 Posts

Posted - 2005-08-11 : 15:14:05
1. If you're going to do an INSERT...SELECT, leave out the values key word.
2. If it returns more than one record, then more than one record will be inserted. Is that a problem?

---------------------------
EmeraldCityDomains.com
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2005-08-11 : 15:16:16
To be clear....


INSERT INTO rules(RuleText)
SELECT RuleText
FROM temp_groupRules


Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-08-12 : 01:29:37
and make sure data type of RuleText of both the tables is identical

Madhivanan

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

- Advertisement -