Showing posts with label regarding. Show all posts
Showing posts with label regarding. Show all posts

Friday, March 23, 2012

EXEC / Sp_executesql with Dynamic SQL string exceeding 4000 - SQL Server 2000


This is regarding the sp_executesql and the sql statement parameter, in processing a dynamic SQL on SQL Server 2000, in my stored procedure.

I have my SQL string exeeding more than 4000 characters.
The sp_executesql expects its parameters to be declared as nvarchar/ntext.
ntext cannot be declared for a local variable and nvarchar has a maximum limit of 4000 characters.

The following was the original approach.
===============
DECLARE @.sql nvarchar(4000),

--
select @.sql=@.sql+'select.................'
--
--
INSERT INTO #Temp
EXEC sp_executesql @.SQL,@.paramlist

===============================

The above sql was split into two sql variables and tried in the following way.
==============================
DECLARE @.sql nvarchar(4000), @.sql1 nvarchar(4000),@.paramlist nvarchar(4000)

--
select @.sql=@.sql+'select.................'
select @.sql1=@.sql1+'from table1, table2.........'
--
--

INSERT INTO #Temp
exec('EXEC sp_executesql ''' + @.sql + @.sql1 + ''',@.paramlist')
====================

However, it compiles correctly but during the execution, the error indicates as syntax error.
I ran the resulting SQL string (@.sql + @.sql1) separately, and it runs fine without any syntax errors returning rows, but when execute through
sp_executesql, it gives me error

Appreciate if anyone can suggest a workaround for this situation.

Try the other version of executing dynamic SQL the simple one....

EXEC(@.sql + @.Sql1)

Because i have used this 2 one place where my Dynamic SQl even exceeds 1lakh characters....|||

Thanks Mandip. It's working. Appreciate your help.

Sunday, February 19, 2012

Excel to Crystal Report

I wish to create a crystal report from an Excel workbook that contains many sheets. Each sheet contains data regarding a one project each. All sheets are of the same format in displaying data. How do I create a crystal report from this workbook, so that the data in the crystal report is displayed as treeview of which the project data itself can be expanded and minimised? Finally this has to be installed in the client's computer. Should I create an addin? You experts out there, please suggest and help me.

ThanksPlease help. No gurus?|||Create a new Report
When selecting Datasource choose the option Access/Excel
Then Choose Database type as Excel
Then Choose name the Excel file
Do the normal procedure thereafter|||Thanks. I will try that.
Thanks|||Did the prior answer to your question help? It seems that you don't need to go from Crystal to Excel but to format a Crystal report to match an Excel spreadsheet. Is that correct?

I have a similar problem. I am trying to convert to Crystal Reports a very complicated Excel worksheet that integrates with a tool that directly pulls data from an Oracle db. With Excel, they "cherry-pick" which accounts they want on any particular row.

In Crystal, you have some control over placing groups and naming them. This approach may work (Group->specified order) but it would be (1) extremely tedious as there are hundreds of lines, (2) I may exceed its capacity, (3) it would be hard for client to support, and (4) it may not work!

Have you found anything that might help?

Thanks!