Showing posts with label character. Show all posts
Showing posts with label character. Show all posts

Wednesday, March 21, 2012

Name cannot begin with the '>' character, hexadecimal value 0x3E

Hi,

This is my first attempt at SSRS, I've added code section to the xml file. But when I use <> for not equal to, it is giving me this error. What should I do? The code is as posted here.

Thanks,

Debi

***************************************************************************************

<Code>
Dim PrevId as Object
Dim a_Count As Double
Dim b_Count As Double
Dim c_Count As Double
Dim d_Count As Double
Dim e_Count As Double
Dim Total As Double = 0
Function SumMPCount(ByVal CurrID As Object,ByVal code As Object, ByVal NewCount As Object) As Double

If(CurrID is Nothing or code is Nothing or NewCount is Nothing)Then
Exit Function
End if
If PrevId Is Nothing Then
PrevId = CurrId
End if
If CurrID <> PrevID Then
a_Count = 0
b_Count = 0
c_Count = 0
d_Count = 0
e_Count = 0
Total = 0
End if
Select Case mp_Code
Case "a"
a_Count = a_Count + NewCount
SumMPCount = a_Count
case "b"
b_Count = b_Count + NewCount
SumMPCount = b_Count
case "c"
c_Count = c_Count + NewCount
SumMPCount = c_Count
case "d"
d_Count = d_Count + NewCount
SumMPCount = d_Count
case "e"
Total = a_Count + b_Count + c_Count + d_Count + e_Count
SumMPCount = Total
case else
e_Count = e_Count + NewCount
SumMPCount = e_Count
End Select

PrevId = CurrId
End Function
</Code>

It looks like you directly copy&pasted the code snippet into the RDL(XML) file and therefore the <> is not encoded an is interpreted as invalid xml element.

You have two options - either copy&paste the code snippet into the report designer custom code window (and report designer will automatically encode the characters correctly), or replace the <> in the RDL file with &lt;&gt; (which is the encoded representation).

-- Robert

|||

Thanks for the reply. Where is the custom code window? When I right click on the report and select properties, it just shows me the usual Properties tab on the RHS which shows background color, image, etc..

I actually worked around it using Object variables and using "Is" instead of <> .

|||I think he might have meant
right click on the report.rdl -> Prooperties -> Code tab -> paste theresql

Monday, March 19, 2012

N'' character in INSERT

Hi,

for example:

INSERT INTO TABLE (FIELD1, FIELD2) VALUES (N' value1', N' value2') WHERE ......

What does N' mean?

Thank you.

N identifies the given string is the UNICODE string. Which will be used when you store the values on NVARCHAR.

If you want to store other than English(or Latin based) in your table (globalization) then you have to use NVARCHAR as your string datatype the N is prefixed to identify the given string is Unicode char.

If you failed to give N prefix on Unicode string the SQL Server try to covert the value to ascii based string and the output printed with question marks

Select '日本語' Output

/*

-

?

*/

If you prefix N then string parsed perfectly,

Select N'日本語' Output

/*

Output

日本語

*/

|||Ok. Thank you very much.

N'' character in INSERT

Hi,

for example:

INSERT INTO TABLE (FIELD1, FIELD2) VALUES (N' value1', N' value2') WHERE ......

What does N' mean?

Thank you.

N identifies the given string is the UNICODE string. Which will be used when you store the values on NVARCHAR.

If you want to store other than English(or Latin based) in your table (globalization) then you have to use NVARCHAR as your string datatype the N is prefixed to identify the given string is Unicode char.

If you failed to give N prefix on Unicode string the SQL Server try to covert the value to ascii based string and the output printed with question marks

Select '日本語' Output

/*

-

?

*/

If you prefix N then string parsed perfectly,

Select N'日本語' Output

/*

Output

日本語

*/

|||Ok. Thank you very much.

N'' character in INSERT

Hi,

for example:

INSERT INTO TABLE (FIELD1, FIELD2) VALUES (N' value1', N' value2') WHERE ......

What does N' mean?

Thank you.

N identifies the given string is the UNICODE string. Which will be used when you store the values on NVARCHAR.

If you want to store other than English(or Latin based) in your table (globalization) then you have to use NVARCHAR as your string datatype the N is prefixed to identify the given string is Unicode char.

If you failed to give N prefix on Unicode string the SQL Server try to covert the value to ascii based string and the output printed with question marks

Select '日本語' Output

/*

-

?

*/

If you prefix N then string parsed perfectly,

Select N'日本語' Output

/*

Output

日本語

*/

|||Ok. Thank you very much.

Saturday, February 25, 2012

my script not working when the name of a DB has - (the dash character)

Hi, this script uses MSforEachDB to check all the SPs in all the databases and look for a keyword LockCookie.

The script runs well except when there is a database with a dash - in ots name.
ie: When ? in the script is replaced by a database whose name contains a dash - the dash and the rest of the database name after the dash is ignored.

And I get the message for example:
Could not locate entry in sysdatabases for database 'SharePoint_AdminContent_f5c0f71f'. No entry found with that name. Make sure that the name is entered correctly.

Here is the script:
exec sp_MSforeachDB
'
use ?
select ''LockCookie'' as searchedTxt, o.name AS ProcName ,Len(SubString(object_definition(o.object_id),1, PatIndex(''%LockCookie%'', object_definition(o.object_id))))-Len(Replace(SubString(object_definition(o.object_id),1, PatIndex
(''%LockCookie%'', object_definition(o.object_id))),char(13),''''))+1 AS Line,
PatIndex(''%LockCookie%'', object_definition(o.object_id)) AS Position, ''?'' as dbName
from ?.sys.objects as o
where o.type=''P'' and object_definition(o.object_id) like ''%LockCookie%''
ORDER BY searchedTxt,ProcName, Line, position'

You can run it and if u have a DB named: sgfgdffgdfd-jjjjj-hhhhh for example you will see the error
How can I fix my script to consider databases with - as well in sys.objects

Thanks a lot for your help.

You might want to try enclosing the database name in square bracked so that

sgfgdffgdfd-jjjjj-hhhhh

becomes

[sgfgdffgdfd-jjjjj-hhhhh]


Dave

|||

yeah man. but what do i do in my script

the script is dynamic:

try jus this little script and it gives the error:

exec sp_MSforeachDB
'
use ?
select o.name,
''?'' as dbName
from ?.sys.objects as o
where o.type=''P'''

Thanks a lot

|||

I changed it to:

exec sp_MSforeachDB
'
use ?
select o.name,
''?'' as dbName
from [?].dbo.sysobjects as o
where o.type=''P'''

and it works fine against all of my databases -- even against my [test-hyphen] database.


Dave

|||

same problem man. did u try it?

thank thee

|||

I got the same error you did with your original query; this version eliminates the execution errors.

exec sp_MSforeachDB
'
use [?]
select ''LockCookie'' as searchedTxt, o.name AS ProcName ,Len(SubString(object_definition(o.object_id),1, PatIndex(''%LockCookie%'', object_definition(o.object_id))))-Len(Replace(SubString(object_definition(o.object_id),1, PatIndex
(''%LockCookie%'', object_definition(o.object_id))),char(13),''''))+1 AS Line,
PatIndex(''%LockCookie%'', object_definition(o.object_id)) AS Position, ''?'' as dbName
from [?].sys.objects as o
where o.type=''P'' and object_definition(o.object_id) like ''%LockCookie%''
ORDER BY searchedTxt,ProcName, Line, position'

Dave

|||

amazing what did u change amigo how many "?"

u re d man

|||never mind amigo thanks a lot