Wednesday, November 27, 2013

Error The query did not run, or the database table could not be opened. Excel 2010

Getting following error when running Stored proc with temp tables in EXCEL 2010


"The query did not run, or the database table could not be opened.
Check the database server or contact your database administrator. Make sure the external database is available and hasn't been moved or reorganized, then try the operation again."

Use folling code at the beginning of the stored proc 
SET NOCOUNT ON

Tuesday, November 26, 2013

Character index sql-server in loop , data in Table

declare

@bu varchar(300)

set

@bu=',0100000011,0100000050,0100000051,0100000026,'

create

table #tempmaintable( inpbu varchar(12))

DECLARE

@Str NVARCHAR(MAX)

SET

@Str = @bu

DECLARE

@Part NVARCHAR(MAX)

DECLARE

@IND INT

SET

@IND = CHARINDEX(',',@Str)

DECLARE

@EIND INT set @EIND = 0

WHILE

(@IND != LEN(@STR))

BEGIN

SET @EIND = ISNULL(((CHARINDEX(',', @Str, @IND + 1)) - @IND - 1), 0)

insert into #tempmaintable SELECT (SUBSTRING(@Str, (@IND + 1), @EIND))

SELECT @IND = ISNULL(CHARINDEX(',', @STR, @IND + 1), 0)

END

select

* from #tempmaintable