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...Execute Problem with text data type

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2003-09-04 : 08:25:37
Peter writes "Hi,

I have run the following codings in SQL SERVER 7 (SP2 and SP4) using Windows 2000 Server, Windows XP Professional, or Windows NT Server:
create table #temp (a text, b text)
insert into #temp values('', '') -- 1 row affected
insert into #temp select '' as a, '' as b -- 1 row affected
execute("insert into #temp " + "select '' as a, '' as b") -- 1 row affected
insert into #temp execute("select '' as a, '' as b") -- 0 row affected
insert into #temp execute("select ' ' as a, '' as b") -- 0 row affected
insert into #temp execute("select ' ' as a, ' ' as b") -- 1 row affected
insert into #temp execute("select '' as a, ' ' as b") -- Error (Note: Be careful about this. I have experienced that the query may keep running and the query cannot be cancelled. I need to stop the sql server service.)

However, running any of the insert statements in SQL Server 2000 will have 1 row affected. So far, I cannot explain this problem but I believe this is related to both text data type and using insert...execute. I have a feeling that it is a bug in SQL Server 7 regardless of what service pack is applied.

Also, what is the difference between the following 2 statements since they behave differently in SQL Server 7?:

execute("insert into #temp " + "select '' as a, '' as b") -- 1 row affected
insert into #temp execute("select '' as a, '' as b") -- 0 row affected "

Stoad
Freaky Yak Linguist

1983 Posts

Posted - 2003-09-04 : 09:26:41
But

insert into #temp execute("select '''' as a, '''' as b")

affects 1 row too...

(in bold 8 single quotes)
Go to Top of Page
   

- Advertisement -