ODBC connection Query shows no resultt

antonh

New Member
Joined
Mar 25, 2013
Messages
4
ODBC connection Query shows no result

Does anyone know why this sql query doesn't return values? My excel version is 2007.

Thanks in advance.

Code:
if object_id( 'TEMPDB..#TMPDOC') is not null
begin
  drop table #TMPDOC
end
 
create table #TMPDOC (Code varchar(5) NOT NULL)
 
 
insert into #TMPDOC (code) VALUES
('AAAAA'),
('BBBBB'),
('CCCCC'),
('DDDDD'),
('EEEEE')


select * from #TMPDOC


if object_id( 'TEMPDB..#TMPDOC') is not null
begin
  drop table #TMPDOC
end
 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
Re: ODBC connection Query shows no result

I know it does.. It doesn't work in excel however
 
Upvote 0
Re: ODBC connection Query shows no result

I know it does.. It doesn't work in excel however

By the process of elimination, that indicates your ODBC parameters are incorrect.

Post them together with your SSMS connection details.
 
Upvote 0
Re: ODBC connection Query shows no result

I don't think it has anything to do with my connection while it doesn't throw me an error and simple statements like 'Select * from dbo.table' do work.
 
Upvote 0
Setting NOCOUNT ON at the beginning of the query and turning it off at the end of the query solved the problem:
Code:
SET NOCOUNT ON
if object_id( 'TEMPDB..#TMPDOC') is not null
begin
  drop table #TMPDOC
end
 
create table #TMPDOC (Code varchar(5) NOT NULL)
 
 
insert into #TMPDOC (code) VALUES
('AAAAA'),
('BBBBB'),
('CCCCC'),
('DDDDD'),
('EEEEE')

select * from #TMPDOC

if object_id( 'TEMPDB..#TMPDOC') is not null
begin
  drop table #TMPDOC
end
SET NOCOUNT OFF
 
Upvote 0

Forum statistics

Threads
1,213,536
Messages
6,114,213
Members
448,554
Latest member
Gleisner2

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top