Showing posts with label characters. Show all posts
Showing posts with label characters. Show all posts

Monday, March 26, 2012

Memo Data Type

I am transferring my access backend to sql 2005. access has a memo
data type. I tried using NVarChar(MAX), it will let me enter 254
characters. Then it gives me an error that the field is too small - it
won't even accept the 254. Is there another data type in SQL that I
can use that would be similar to the memo data type?
-doodleWhere are you trying to enter data, what is the exact error message
you are getting, and what application is generating the error?
-- Steve Kass
-- Drew University
-- http://www.stevekass.com
doodle wrote:
>I am transferring my access backend to sql 2005. access has a memo
>data type. I tried using NVarChar(MAX), it will let me enter 254
>characters. Then it gives me an error that the field is too small - it
>won't even accept the 254. Is there another data type in SQL that I
>can use that would be similar to the memo data type?
>-doodle
>
>

Memo Data Type

I am transferring my access backend to sql 2005. access has a memo
data type. I tried using NVarChar(MAX), it will let me enter 254
characters. Then it gives me an error that the field is too small - it
won't even accept the 254. Is there another data type in SQL that I
can use that would be similar to the memo data type?
-doodleHi
"doodle" wrote:
> I am transferring my access backend to sql 2005. access has a memo
> data type. I tried using NVarChar(MAX), it will let me enter 254
> characters. Then it gives me an error that the field is too small - it
> won't even accept the 254. Is there another data type in SQL that I
> can use that would be similar to the memo data type?
> -doodle
>
nvarchar(max) can hold 2^31 -1 bytes see
http://msdn2.microsoft.com/en-gb/library/ms130896.aspx. It is most likely a
limit of the application that you are using that restricts imput/output to
254 bytes, for instance the tools/options menus in Query Analyser or SQL
Server Management Studio can be configure to set how many characters are
displayed.
John|||John,
I checked it in SQL, it is currently set to 2147483647 bytes. What do
I need to change it to?
-doodle|||"doodle" <ADraughn@.mazakcorp.com> wrote in message
news:1172510102.622413.4400@.k78g2000cwa.googlegroups.com...
> John,
> I checked it in SQL, it is currently set to 2147483647 bytes. What do
> I need to change it to?
> -doodle
>
I don't believe you can. If you need to store more than 2 gigs in a memo,
you may want to rethink your datastructure.
(perhaps a pointer to a file on a disk or something.)
Greg Moore
SQL Server DBA Consulting
sql (at) greenms.com http://www.greenms.com|||Hi
"doodle" wrote:
> John,
> I checked it in SQL, it is currently set to 2147483647 bytes. What do
> I need to change it to?
> -doodle
>
You do not say how you are updating this value a statement such as
UPDATE MyTable
SET MyMemoColumn = 'A very long memo text that is much longer than this'
Will work fine.
To see what size this value is use the query
SELECT LEN(MyMemoColumn)
FROM MyTable
Query Analyser will not allow you to set a the number of output characters
to a value as large as 2147483647 neither will SSMS which has a maximum
display value of 8192. How did you obtain this figure?
John|||It's being updated by forms in access 97.
-doodle|||Hi
"doodle" wrote:
> It's being updated by forms in access 97.
> -doodle
>
Did you run the query from my last reply to see how big the data is?
John

Saturday, February 25, 2012

MDX Query above 8000 characters

Hi,

I have a MDX query which is of an aprox length of 10000 characters. I
have to execute the query from within the stored procedure in sql. To
run this query I use the openrowset method.

If the length of my query is less than 8000 characters my query
executes perfectly, but the moment it exceeds 8000 characters it stop
working. Please suggest a solution for the same.

Sample Code:

declare @.mdxqry varchar(8000)
declare @.SearchCond varchar(8000)

set @.SearchCond = @.SearchCond + '
[ProductsAccounts].CurrentMember.properties("AS Date") <= "' + @.TDate
+ '" '

set @.mdxqry = '''WITH ' +
'MEMBER [Measures].[Difference] as ''''[Measures].[Expected Interest
Amount] - [Measures].[Adjusted Interest]'''' ' +
'MEMBER [Measures].[Loan Closed within Report Period] as ' +
''iif(cdate([ProductsAccounts].CurrentMember.properties("Closed
Date")) < cdate("' + @.ToDate + '"), "Yes", "No")'' +
'MEMBER [Measures].[ClosedBeforeLastInstallment] as
''''iif([Measures].[Loan Closed Before Last Instal]=1, "Yes", "No")''''
' +
'SELECT ' +
'{[Measures].[Expected Interest Amount], [Measures].[Adjusted
Interest], [Measures].[Difference], ' +
'[Measures].[Zero Interest Transactions],
[Measures].[ClosedBeforeLastInstallment], ' +
'[Measures].[Loan Closed within Report Period]} ON 0, '

set @.mdxqry = @.mdxqry +
'{Filter([ProductsAccounts].[Account Id].Members, (' + @.SearchCond +
'))} on 2, ' +
@.BranchFilter +
'FROM InterestAnalysis'''

set @.mdxqry = 'SELECT a.* FROM
OpenRowset(''MSOLAP'',''DATASOURCE="SERVERNAME"; Initial
Catalog="DATABASENAME";'',' + @.mdxqry + ') as a'

exec(@.mdxqry)

I have already tried splitting my query into smalled chunks and
executing it, but still I face the same problem.

This is how I have Done it:

declare @.mdxqry1 varchar(8000)
declare @.mdxqry2 varchar(8000)
declare @.SearchCond varchar(8000)

set @.SearchCond = @.SearchCond + '
[ProductsAccounts].CurrentMember.properties("AS Date") <= "' + @.TDate
+ '" '

set @.mdxqry1 = '''WITH ' +
'MEMBER [Measures].[Difference] as ''''[Measures].[Expected Interest
Amount] - [Measures].[Adjusted Interest]'''' ' +
'MEMBER [Measures].[Loan Closed within Report Period] as ' +
''iif(cdate([ProductsAccounts].CurrentMember.properties("Closed
Date")) < cdate("' + @.ToDate + '"), "Yes", "No")'' +
'MEMBER [Measures].[ClosedBeforeLastInstallment] as
''''iif([Measures].[Loan Closed Before Last Instal]=1, "Yes", "No")''''
'

set @.mdxqry2 = 'SELECT ' +
'{[Measures].[Expected Interest Amount], [Measures].[Adjusted
Interest], [Measures].[Difference], ' +
'[Measures].[Zero Interest Transactions],
[Measures].[ClosedBeforeLastInstallment], ' +
'[Measures].[Loan Closed within Report Period]} ON 0, '

set @.mdxqry2 = @.mdxqry2 +
'{Filter([ProductsAccounts].[Account Id].Members, (' + @.SearchCond +
'))} on 2, ' +
@.BranchFilter +
'FROM InterestAnalysis'''

set @.mdxqry2 = 'SELECT a.* FROM
OpenRowset(''MSOLAP'',''DATASOURCE="SERVERNAME"; Initial
Catalog="DATABASENAME";'',' + @.mdxqry + ') as a'

exec(@.mdxqry1 + @.mdxqry2)

Thanks in Advance

Charuvarchar is limited to 8000 characters, but EXEC can take several varchar parameters concatenated together.

Try breaking @.mdxqry into several strings that you know will be below the 8k limit (@.mdxqry1, @.mdxqry2, ...@.mdxqryN). Then call it like this:

exec (@.mdxqry1 + @.mdxqry2 + ... @.mdxqryN)|||I have already tried breaking up the varchar into multiple variables but the same problem exists...Please see if there is any other solution...

Thanks
Charu|||I have already tried breaking up the varchar into multiple variables but the same problem exists...How? Not according to the code you posted.