Showing posts with label errors. Show all posts
Showing posts with label errors. Show all posts

Wednesday, March 21, 2012

Getting row order in Input File when Handling Errors

Hi All,

Well, tha case here is simply that i have a (Suppliers.csv) as an Input.

When taking that file, I do some validation on it's rows (Data type validations, Mandatory Fielda validations..etc).

When some rows to do not meet the requirments i put in these validations , it is supposed to be directed to an (Errors) Table in my SQL DB.

I want to include the order of the invalid row in the input File (The row which did not pass from the pre-mentioned validations) within the (Errors) Table when i direct the invalid rows to it.

Any ideas ?

See the script in my post on surrogate keys.

http://www.ssistalk.com/2007/02/20/generating-surrogate-keys/

Place that at the beginning of your data flow to number all rows passing through it. Then in the error flow, you'll have the correct row number.

Friday, February 24, 2012

Getting errors I dont understand within Create Function

Here is the function I'm trying to write. The purpose is to replace MS Access Val() function. I'm not finished with the logic, I'm just trying to get this much to work now. Here is the function:create function DBO.NumValue
-- This function will get the numbers from the front of a field
-- and return the value of those numbers in a numeric data type
(@.mNumInput as charvar(100))
RETURNS numeric
AS
BEGIN
declare @.x as tinyint
declare @.x1 as tinyint
SET @.x = 1
WHILE IsNumeric(SubString(@.mNumInput, @.x, 1))
BEGIN
SET @.x1 = @.x
SET @.x = @.x + 1
CONTINUE
END
If @.x1 > 0
BEGIN
RETURN CAST(LEFT(@.mNumInput, @.x1), Numeric
END
END
Here are the two error messages I'm getting from this function.Server: Msg 156, Level 15, State 1, Procedure NumValue, Line 12
Incorrect syntax near the keyword 'BEGIN'.
Server: Msg 156, Level 15, State 1, Procedure NumValue, Line 20
Incorrect syntax near the keyword 'END'. I have no idea what these two error messages mean.
TIA,Here is the function I'm trying to write. The purpose is to replace MS Access Val() function. I'm not finished with the logic, I'm just trying to get this much to work now. Here is the function:create function DBO.NumValue
-- This function will get the numbers from the front of a field
-- and return the value of those numbers in a numeric data type
(@.mNumInput as charvar(100))
RETURNS numeric
AS
BEGIN
declare @.x as tinyint
declare @.x1 as tinyint
SET @.x = 1
WHILE IsNumeric(SubString(@.mNumInput, @.x, 1))
BEGIN
SET @.x1 = @.x
SET @.x = @.x + 1
CONTINUE
END
If @.x1 > 0
BEGIN
RETURN CAST(LEFT(@.mNumInput, @.x1), Numeric
END
END
Here are the two error messages I'm getting from this function. I have no idea what these two error messages mean.
TIA,

The error messages mean you have syntax errors in your function definition.

You've got a few issues:

1. there's no such type as charvar. I think you mean varchar
2. a while condition needs to evalulate to a boolean. but isnumeric returns 1 or 0 (an int). so you need this: WHILE IsNumeric(SubString(@.mNumInput, @.x, 1)) = 1
3. your cast at the end has syntax errors.
4. you don't return a value at the end if the IF isn't satisfied. all functions must return a value. Here's your corrected function:

create function DBO.NumValue
-- This function will get the numbers from the front of a field
-- and return the value of those numbers in a numeric data type
(@.mNumInput as varchar(100))
RETURNS numeric
AS
BEGIN
declare @.x as tinyint
declare @.x1 as tinyint
SET @.x = 1
WHILE IsNumeric(SubString(@.mNumInput, @.x, 1)) = 1
BEGIN
SET @.x1 = @.x
SET @.x = @.x + 1
CONTINUE -- continue isn't necessary here, but whatever.
END
If @.x1 > 0
BEGIN
RETURN CAST(LEFT(@.mNumInput, @.x1) as Numeric)
END
return -1 -- if no digits found at the beginning of the string
END

sample usage:

select dbo.NumValue('asdf') -- returns -1
select dbo.NumValue('555asdf') -- returns 555|||jezemine,
Thank you VERY much for your reply. I'm a VBA programmer, so this T-SQL coding language is still a little awkward, therefore, this question:
WHILE IsNumeric(SubString(@.mNumInput, @.x, 1)) = 1
BEGIN
SET @.x1 = @.x
SET @.x = @.x + 1
CONTINUE -- continue isn't necessary here, but whatever.
END
You said the Continue is not necessary here, but I thought the Continue was the "Loop back to the Where statement" command. How else do you get the "Where" to loop?
Thanks for your patience!|||it will loop from the point where you have END.

you only use continue if you want to jump back to the beginnign of the loop before END, that is, if you have statements between continue and end that you don't want to be executed on a particular pass thru the loop.

Certainly they have while loops in VB, don't they?|||Of course there are loops in VB, but with differing syntax. Within VB, there is no equivilent to "Continue" in T-SQL. Rather than using a command statement such as "Continue", in VB if there are lines after a certain point that should not be executed, that would be done with an If statement. There is only one Loop point in VB. So, this was not a conceptual question (what is a loop?) but a syntax question because of a new language. And, this is the first language for me that uses the concept of a Begin/End I have seen enough of Java and C to know that both of them have that same concept, but as far as writing in a language that uses this concept, this is new and different.
Thanks a ton for your help and I will be asking some more questions, soon.|||so in VB they have while loops, but no way to go back to the beginning of the loop early?

I know nothing of VB, my question was an honest one. :)|||Sample VB While Loop:
While TestIsTrue
i = i + 1
If i > 5 then
j = j + 2
End If
WEnd 'End of While, therefore loop until TestIsTrue becomes equal to False.
Same While loop in T-SQL (as I understand it)
While @.TestIsTrue
Begin
@.i = @.i + 1
If @.i <= 5 Continue
@.j = @.j + 2
End

I'm not sure I got the T-SQL syntax correct, but I tried. :)
And yes, I know there is no way out of my loop, but I really don't think it was that important.|||i see.

In T-SQL, it's more similar to what you have in C/C++ (you can use continue to jump to the top, or break to break out)

For flow control in sql, a good resource is BOL:

http://msdn2.microsoft.com/en-us/library/ms189826.aspx
http://msdn2.microsoft.com/en-us/library/ms178642.aspx (funny thing about the first example on this page is they have a noop continue just like you had :))

Getting Errors during Synchronization

Guys,

I am getting errors during synchronizing a database. It completes 96% and then throws this error:

"Internal error: An unexpected exception occured. Backup and restore errors: An error occurred while synchronizing the 'XXX' database."

I was able to synchronize this database from another server where it was processed just fine.

The only changes that I think I made was change the partition locations. We have 2 cubes with 9 partitions each. One cube with all its partitions goes to the default D:\Program Files\Microsoft SQL Server\MSSQL.1\OLAP\ folder.

The other cubes has 9 partition we are changing the location to go to these folders:

E:\XXX Cube Data -- 3 partitions

F:\XXX Cube Data -- 3 partitions

G:\XXX Cube Data 3 partitions

I am not able to understand as to what to check here.

I looked at flight recorder and it gives the same

"Internal error: An unexpected exception occured. Backup and restore errors: An error occurred while synchronizing the 'XXX' database."

Not sure as to what to do.

Any suggestions.


Rgds

Hari

I'm assuming that your target server has E,F and G drives, but have you created the full paths ("XXX CubeData") and does the account that SSAS is running under have access to those paths?|||

Yup the two servers are identical and the way we wanted to do it all the processing is done on one server and querying will be done on another server. The servers have identical drives and folders underneath and we are using the same service account to run the servers.

Also when I look at the actual database from the source server by right clicking it from managment studio, I see the size as 3.21MB. However when I go to each of the folders in the different drives, it does not say XXX.1.db or whatever but just contains A313A-42DC-498C-8BBD-3A899313B30E.0.0.0.0
This is on the source server.

In the destination server, I am mapping all the partitions to go to the same location on the destination as they are on the source server.
However it fails...Not sure what else to do.
Is there anything that would give me more details?

On the destination server, I see the following from the event viewer:
Event Type: Error
Event Source: MSSQLServerOLAPService
Event Category: (256)
Event ID: 22
Date: 4/3/2007
Time: 10:07:39 AM
User: N/A
Computer: XXXXXXXXXXXXXXXXXXXX
Description:
The description for Event ID ( 22 ) in Source ( MSSQLServerOLAPService ) cannot be found. The local computer may not have the necessary registry information or message DLL files to display messages from a remote computer. You may be able to use the /AUXSOURCE= flag to retrieve this description; see Help and Support for details. The following information is part of the event: Internal error: An unexpected exception occured..


Rgds

Hari

|||

Any error that starts with "Internal error" is not good. I think you can change the path where the partitions are stored in the synchronisation script, but I thought the default was the same as the source server.

You could try running SQL Profiler on the source and destination servers to see if you get any more information or possibly some more context around what is going on when the error occurs. You could also try running FileMon (http://www.microsoft.com/technet/sysinternals/FileAndDisk/Filemon.mspx) this can trace all the file based activity on a machine and you can see if there are any permissions or other errors trying to access a disk resource.

Have you tried doing a back up and restore to the destination server? I am pretty sure that they use the same underlying mechanism, but maybe you will get a better error message.

Otherwise this might require a support call.

|||

Just an FYI...

This has been logged as a bug on Analysis Services 2005 sp1.

It has been fixed and works fine on sp2.

Reference: SQL BU Defect Tracking 514484

The actual problem is when you are changing the storage locations on the source server and trying to synchronize it to the destination server.


Rgds

Hari

Getting error while running upgrade advisor on remote virtual server

Hi,

While connecting remote SQL server through upgrade advisor I am getting the below errors:

Error: Unable to connect to server. Reason: An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)

Pls let me know if anyone has faced this issue and know how to fix.

Thanks in advance


-Shriniwas

just go to sql server surface area configuration and choose surface area configuration for services and connections then under mssqlserver-->database engine>choose remote connections and in right side page choose local and remote connections and using named pipes and tcp or 1st option with only tcp