How Do You Make Use Of ErrorCode And ErrorColumn

Feb 1, 2007



SSIS automatically adds the columns ErrorCode and ErrorColumn to the error pipe routing bad rows. However, both these columns appear to be meaningless. We need to translate the error column to the actual problem column and the error code to a meaningful error. ErrorColumn is the more important issue for us. The question is 'Are these just useless columns? If not, how do we translate them into something useful?'

Thanks

View 1 Replies


ADVERTISEMENT

Best Practices: Recording Error Information (Beyond ErrorCode And ErrorColumn)

Sep 6, 2007

I'm sorry for asking this, as I'm sure tha the answer is in one of the 208 matches I found searching on "ErrorCode". Unfortunately, this project is overdue and I need a solution fairly soon.

I should add that I've only been developing in SSIS since August 2007.

I have a complicated package, loading about 17 outputs of the XML Source into staging tables. I have been using the error outputs of any standard components I use, out of faith that, if Microsoft provided them, then they should be useful for something. I've been directing all of the error outputs for one of the 17 "tables" from the XML Source into a Union All, and then into an "Error staging table", for each of the 17 outputs. This table includes all of the possible columns, but permits nulls for all of them. It also incldues the ErrorCode and ErrorColumn.

Unfortunately, if these latter two are useful for anyting, I haven't found it yet.

Right now, working with our first "mostly real" data, I'm getting 100% of my input rows written into error tables. Unfortunately, the information in the tables are of limited use in determining what went wrong. For instance, the ErrorColumn seems only to be populated if there was a specific error with a specific column. The Lookup component, doesn't seem to populate ErrorColumn, even if only one column was used for the lookup! No information about the component producing the error output is supplied in the error output, either, which makes it difficult to determine which of the five or so possible error outputs is the one that produced the particular error row.

This proves that I'm missing something simple. How do people handle errors? In my custom components, I learned to use the Fire* methods to produce detailed messages before redirecting the row to the error output, but this sort of thing is not available through the standard components.

Do I really have to create a separate "add useful information to the error output" component, and use it on each error output?

Sorry for the attitude, but just when I think I'm winning, SSIS brings me back down to earth!

View 5 Replies View Related

ErrorColumn Output

Oct 26, 2007

How to find the actual column name of error column? The error output has ErrorColumn parameter but it is the number ( i.e 11219).. how can I convert it to the actual column name in the table?

View 1 Replies View Related

How To Get The Name Of The Error Column From The Errorcolumn Output

Apr 2, 2007

Hi,

Iam redirecting the error output of a OLEDB destination component to a script component. My aim is to create a HTML report having the information about the bad records, the error occuring in the rows and the column name that fails. The error output provided two new columns i.e the errorcode and errorcolumn , the errorcolumn value for a bad record gives the linage id for the column, is there a way to derieve the name of the column by using the lineage id?

Regard,

pritesh

View 5 Replies View Related

URGENT: Obtaining Actual Name Of ErrorColumn Instead Of Its LineageID.

Mar 21, 2007

Hi,

In a dataflow, I've an OLE DB source before a script component.
When I link the Red Output of the source to the script component, I want to get the COLUMN NAME (which is the source of error), instead of the default ErrorColumn (LineageID). I'm not able to succeed with the following code snippet.

My code is something like this:

Dim temp_Int_EmpID As Microsoft.SqlServer.Dts.Pipeline.Wrapper.IDTSInputColumn90
temp_Int_EmpID = Microsoft.SqlServer.Dts.Pipeline.Wrapper.IDTSInputColumnCollection90.GetInputColumnByLineageID(Row.ErrorColumn)

Pls. let me know if it's possible to achieve what I require & if so, how.

Kindly reply at the earliest !

Regards,
Natesh PV

View 1 Replies View Related

ErrorColumn Field From Datasource Error Output

Feb 8, 2007

Hi,

The problem is, ErrorColumn contains ID. Is the following code reference safe ?
columnname = Me.ComponentMetaData.InputCollection.FindObjectByID(Row.ErrorColumn).Name


Is there any possibility for FindObjectByID to return NULL Reference in any case ?

View 8 Replies View Related

ErrorCode 14

Sep 15, 2006

I've scripted a sql trace for Sql Server 2000 and added the filename in the appropreate location andthe result is a column called ErrorCode with a value of 14. Can anyone tell me what this error code means and what could be infered about what I need to resolve it?

Thanks,
Marc

View 1 Replies View Related

OleDbException ErrorCode

Feb 26, 2007

When a user finally confirms his order in a shopping cart application (using MS-Access as the backend), the items he has purchased are populated in a Access DB table named Orders & his personal details (like name, mail, billing address, shipping address etc.) are populated in another table named CustDetails. Both the DB tables have a column named OrderID. This column is the Primary Key in the CustDetails table & the Foreign Key in the Orders table. The Session.SessionID becomes the unique OrderID.After confirming an order, if the user refreshes the page, the app will try to populate the same Session.SessionID in the CustDetails table but since the column OrderID is a Primary Key column in the table CustDetails, it won't accept duplicate OrderIDs. Under such circumstances, an OleDbException will be raised.Since a DB app can throw other OleDbExceptions other than the one about which I mentioned above, I want to display custom error messages to the user. For e.g. if he refreshes the page after confirming his order, I want to display a message saying "Your order has already been placed".To do this, I tried using the ErrorCode property of the OleDbException class but what I found is the ErrorCode changes from time to time! Had a particular ErrorCode been assigned to the error, I could have done something like this (assuming that the ErrorCode for the above error is -12345 which is constant):Try    'some codeCatch ex As OleDbException    If (ex.ErrorCode = -12345) Then        Response.Write("Your order has already been placed")    ElseIf (ex.ErrorCode = <some other constant ErrorCode>) Then        Response.Write("Another custom error message")    End IfEnd TryBut I can't do the above since the ErrorCode changes from time to time.So how do I display custom error messages to users under such circumstances?Of course, I can use the Message property of the OleDbException class but that would be a rather tedious workaround.

View 4 Replies View Related

ErrorCode 8144

Jun 14, 2008

Hi,
In my local , application is working fyn...but when i had uploaded in the file in Live and executed the SP's ,It is showing up the error 8144...
Whene i had checked in google it is showing:
has too many arguments specified: Msg 8144....But i had not passed to many arguments...
(The same SP is working in local but not in live)...
The related files also i had shifted to live...

This is the SP I Have used....
while Submiting iam getting error
GO

SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO



--- STORED PROCEDURE USP_CREATE_USER TO SAVE THE APPLICATION INFORMATION INTO DATABASE


CREATE PROCEDURE dbo.USP_CREATE_APPLICATION_ONLINE
(

@ApplicationID INT,
@Broker CHAR(1),
@Name VARCHAR(30),
@Phone VARCHAR(15),
@Email VARCHAR(50),
@LoanAmount Decimal(9),
@LoanPurpose VARCHAR(200),
@DeedType_ID VARCHAR(50),
@SubDeedType_ID INT,
@DeedAddress VARCHAR(200),
@City VARCHAR(50),
@CountryID INT,
--@StateID INT,
@MarketValue Decimal(9),
@LoanTerm INT,
@Appraised CHAR(3),
@Comments VARCHAR(50),
@DeleteFlag VARCHAR(1),
@RETURN int OUT,
@ERRORCODE int OUT
)

AS
set @RETURN=1
SET NOCOUNT ON


iF EXISTS(SELECT * FROM APPLICATION_ONLINE WHERE ApplicationID=@ApplicationID)
Begin
BEGIN TRANSACTION TRANSUPDATE
UPDATE APPLICATION_ONLINE SET

ApplicationID = @ApplicationID,
Broker = @Broker,
[Name] = @Name,
Phone = @Phone,
Email = @Email,
LoanAmount=@LoanAmount,
LoanPurpose=@LoanPurpose,
DeedType_ID=@DeedType_ID,
SubDeedType_ID=@SubDeedType_ID,
DeedAddress =@DeedAddress,
City =@City,
CountryID = @CountryID,
MarketValue = @MarketValue,
LoanTerm = @LoanTerm,
Appraised =@Appraised,
Comments =@Comments

WHERE [ApplicationID] = @ApplicationID

SET @ERRORCODE=@@ERROR
IF @ERRORCODE <> 0
BEGIN
ROLLBACK TRANSACTION TRANSUPDATE
SET @ERRORCODE=@@ERROR
RETURN
END
ELSE
BEGIN
COMMIT TRANSACTION TRANSUPDATE
SET @ERRORCODE=50002
RETURN
END

END

else

BEGIN
BEGIN TRANSACTION TRANSINSERT
INSERT INTO APPLICATION_ONLINE(
ApplicationID,
Broker,
[Name],
Phone,
Email,
LoanAmount,
LoanPurpose,
DeedType_ID,
SubDeedType_ID,
DeedAddress,
City,
CountryID,
-- StateID,
MarketValue,
LoanTerm,
Appraised ,
Comments,
DeleteFlag
)
VALUES
(
@ApplicationID,
@Broker,
@Name,
@Phone,
@Email,
@LoanAmount,
@LoanPurpose,
@DeedType_ID,
@SubDeedType_ID,
@DeedAddress,
@City,
@CountryID,
-- @StateID,
@MarketValue,
@LoanTerm,
@Appraised,
@Comments,
@DeleteFlag

)

SET @ERRORCODE=@@ERROR
IF @ERRORCODE <> 0
BEGIN
ROLLBACK TRANSACTION TRANSINSERT
SET @ERRORCODE=50004
RETURN
END
ELSE
BEGIN
COMMIT TRANSACTION TRANSINSERT
SET @ERRORCODE=50001
RETURN

END

END



GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO

Thanks

View 3 Replies View Related

ErrorCode Description

Dec 11, 2007



This is a request to the Microsoft SSIS staff.
I did a search for the keywords in the description and can already see a lot of people frustrated about this.

A lot of well designed integration packages will route error messages to an error table or file.
SSIS appends a couple of extra error columns called ErrorCode and ErrorColumn. At runtime, an extra
column is visible in the DataViewer called ErrorCode - Description.

The description is hardcoded into the dtsmsg.h file in the SDK folder of Sql Server.
This file is very hard to parse.

Can some from SSIS please post an XML or CSV file with all the error codes and descriptions for us to download please.
This will be such a big help in debugging.

Many Thanks.


Shailen Sukul
Software Architect/Developer/Consultant
(BSc | Mcts (Biztalk (IP)) | Mcpd | Mcts (Web, Win, Dist Apps) | Mcsd.NET | Mcsd | Mcad)
Ashlen Consulting Services Pty Ltd
(http://www.ashlen.com.au)
MSN | Skype | GTalk Id: shailensukul
Ph: +61 0421 277 812
Fax: +61 3 9011 9732
Linked In: http://www.linkedin.com/in/shailensukul

View 3 Replies View Related

Sp_create_trace Throws Errorcode = 12

Nov 6, 2007

Hi,I'm trying to execute server-side trace with SqlServer 2000 oncluster. After scripting trace by Profiler I executed this script inQueryanalyzer and got error code 12. According to BOL this code saysthat file is not created but I don't know why, is there are anyobstacles which preventing to add this trace??Does anybody had that problem?If it helps I added script which I tried to execute:-- Create a Queuedeclare @rc intdeclare @TraceID intdeclare @maxfilesize bigintset @maxfilesize = 5exec @rc = sp_trace_create @TraceID output, 0, N'C:Profiler_result
esult.trc', @maxfilesize, NULLif (@rc != 0) goto error-- Client side File and Table cannot be scripted-- Set the eventsdeclare @on bitset @on = 1exec sp_trace_setevent @TraceID, 10, 1, @on/*here are n-setevents*/exec sp_trace_setevent @TraceID, 43, 35, @on-- Set the Filtersdeclare @intfilter intdeclare @bigintfilter bigintexec sp_trace_setfilter @TraceID, 1, 1, 6, N'history'exec sp_trace_setfilter @TraceID, 1, 1, 6, N'move_history'exec sp_trace_setfilter @TraceID, 10, 0, 7, N'SQL Profiler'exec sp_trace_setfilter @TraceID, 35, 1, 6, N'kis'-- Set the trace status to startexec sp_trace_setstatus @TraceID, 1-- display trace id for future referencesselect TraceID=@TraceIDgoto finisherror:select ErrorCode=@rcfinish:goThanks in advance for any adviceRegards,Bartolo

View 3 Replies View Related

SQL Express ERRORCODE:37000

Dec 27, 2007

Installed SQL express 2005 w/Studio Manager. Everything installed Ok except got an error IIS was not running or not installed.
When installing a software program, when it tries to create the database I get an error at the initialization:

An error has occured while processing an SQL statement. Please refer to the system administrator guide for further assistance.
ERRORCODE:37000
ERROR:CREATE DATABASE failed. Some of the file names cound not be created. Check related errors.
SQL STATEMENT
CREATE DATABASE xxxx


Has anyone seen or know a fix for this? Thanks in advance.

View 1 Replies View Related

Problem With ErrorCode (DT_NTEXT Not Supported...???)

Jul 21, 2006

Hi again!

I have another problem, this time with a flatfile source component. The file is pretty simple organized and in fact everything works as expected.

The file itself comes from an FTP server, so it is not available at designtime. For setting up the flatfile source i downloaded it, but afterwards i delete it, set 'dalayvalidation' to true and try to execute.

FTP download works fine, the file is there but then i get the errormessage:

Copier ErrorCodes [586]: The data type for "output column "Flat File Source Error Output Column" (610)" is DT_NTEXT, which is not supported with ANSI files. Use DT_TEXT instead and convert the data to DT_NTEXT using the data conversion component.



When i try to set the datatype of the Error Output Column (610) to DT_NEXT i only get an errormessage telling me that this would not be a valid value for this property.

The only chance i have to get it working again is to completely delete the flatfile-source, readd and setup it again, then everything works... but only until i remove the files and try to download them via FTP. It's strange :-( and annoying.

Anyone any idea?

kind regards,

Wolfgang

View 1 Replies View Related

SSIS : ErrorCode OnInformation EventHandler

Feb 18, 2008

Hello,

Within my SSIS packages I use a logging logic quite similar as the one described by Jamie Thomson here : http://blogs.conchango.com/jamiethomson/archive/2005/06/11/SSIS_3A00_-Custom-Logging-Using-Event-Handlers.aspx

But I still have a small "problem". When my package end with success the ErrorCode returned at the OnInformation event handler level is :







0x4001100B


1073811467


DTS_I_COMMITTINGTRANSACTION


Committing distributed transaction started by this container.

Instead of :







0x40013001


1073819649


DTS_MSG_PACKAGESUCCESS


Package "__" finished successfully.

Another example.

When there's an integrity constraint violation, I've got the following ErrorCode returned :







0xC0047021


-1073450975


DTS_E_THREADFAILED


Thread "__" has exited with error code __.

Instead of :







0xC020907D


-1071607683


DTS_E_OLEDBDESTINATIONADAPTERSTATIC_INTEGRITYVIOLATION


The data value violates integrity constraints.

Anyone has a clue ?

Thanks a lot by advance.

Cheers,

Bertrand

View 6 Replies View Related

Copy Database Wizard ErrorCode=-1073548784

Sep 13, 2007



I am transfering a database from sql server 2000 to sql server 2005 using copy database wizard.
I have this error coming up error

Error: ERROR : errorCode=-1073548784 description=Executing the query "EXEC dbo.sp_grantdbaccess @loginame = N'Testusername', @name_in_db = N'username' " failed with the following error: "The login already has an account under a different user name.". Possible failure reasons: Problems with the query, "ResultSet" property not set correctly, parameters not set correctly, or connection not established correctly. helpFile= helpContext=0 idofInterfaceWithError={8BDFE893-E9D8-4D23-9739-DA807BCDC2AC} StackTrace: at Microsoft.SqlServer.Management.Dts.DtsTransferProvider.ExecuteTransfer() at Microsoft.SqlServer.Management.Smo.Transfer.TransferData() at Microsoft.SqlServer.Dts.Tasks.TransferObjectsTask.TransferObjectsTask.TransferDatabasesUsingSMOTransfer()

How do i handle this error...looked online but didn't find right answers...

Please let me know

View 2 Replies View Related

Decoding Decimal Form Of HRESULT From ErrorCode

Mar 2, 2006

I have an OLE-DB Command transformation that inserts a row. If the insert SQL command fails for some reason, I use the "Redirect Row" option to send the row to another OLE-DB Command transformation that logs the error on that row to a "failed rows" table. In this table I log the ErrorCode and ErrorColumn values that come with the error path from the first OLE-DB Command.

OK, that's all working great. However, here's the kicker: there's no error description value. The ErrorCode value, naturally, is the decimal form of an HRESULT--for example, -1071607696. Without some further information, however, this code is not useful for troubleshooting.

Has anyone figured out a trick here? I'm not even certain that this is an SSIS HRESULT, since it could for all I know be from the OLE-DB layer, the database layer, or somewhere else.

Thanks,
Dan

View 7 Replies View Related

Kirk: Importing/Exporting With Column ErrorCode, ErrorColumns

Mar 8, 2006

I am currently redirecting lookup failures into error tables with ErrorCode and ErrorColumn. It works fine until I want to transfer data into the archived database. The SSIS pacakage generate by SQL Exporting tool is throwing an "duplicate name of 'output column ErrorCode and ErrorColumn" error. This is caused by oledb source error output. The error output automatically add ErrorCode and ErrorColumn to the error output selection and not happy with it.

I think the question is down to "How to importing/exporting data when table contains ErrorCode or ErrorColumn column?"

View 5 Replies View Related

Make C#

Jun 30, 2006

Can somebody help me convert this SQL2000 Function TO C# Function pleaseCREATE Function dbo.CalculateNextRentDate ( @Rent_Payment_Date datetime, @Frequency varchar(50) , @Number int)RETURNS DATETIMEASbeginDECLARE @NextPaymentDate DatetimeSET @Number = @Number - 1.IF @Frequency = 'month'    IF  @rent_payment_date = dateadd(month, datediff(month, 0+@Number, @rent_payment_date) + 1, -1)            BEGIN                   SET  @NextPaymentDate = dateadd(month, datediff(month, 0, @rent_payment_date) + 2, -1)           END    ELSE           BEGIN                     SET  @NextPaymentDate =  dateadd(month, 1+@Number, @rent_payment_date)           END    return @NextPaymentDateend

View 1 Replies View Related

Make 2 Or 1

Aug 16, 2007

Our company has its Departments And Services.
Now We are making it online.
Both have separate email list, phone numbers, and more.
Will I make one table and adds the field Type (Values: D or S).
Or make them separate.
Remember one thing If we merge them then Email And PhoneNumber Table will also me merge
other wise they will also separate.
What is better.

View 13 Replies View Related

DTS How Make Our Own?

Mar 29, 2004

How to make our own DTS package I have to split the data on my own.. Data is very biig almost 30 to 40 million. I need to splitt them into 10k chunks in database and with my desired table name.
Waiting for a +tive reply.

Regards

Shani ;)

View 6 Replies View Related

How Can I Make This And Or

Feb 12, 2008



hi i have a tabel in my database i tray to generat report for this tabel
this tabel have all this fields:
company_id
emp_no
seq_no
interval_date
in_time
in_type
out_time
out_type
wage_code
status
i want all his colums can be search
but with company_id
like if he enter company_id and emp_no okay give him result if he enter Company_id and interval_date okay give him result
i write this





Code Snippet
SELECT company_id, emp_no, seq_no, interval_date, in_time, in_type, out_time, out_type, wage_code, status
FROM interval
WHERE (company_id LIKE @CompanyID) AND (emp_no LIKE @EmployeeID) OR
(company_id = @CompanyID) AND (interval_date = @IntervalDate) OR
(company_id = @CompanyID) AND (in_time = @InTime) OR
(company_id = @CompanyID) AND (in_type = @InType) OR
(company_id = @CompanyID) AND (out_time = @OutTime) OR
(company_id = @CompanyID) AND (out_type = @OutType) OR
(company_id = @CompanyID) AND (wage_code = @WageCode) OR
(company_id = @CompanyID) AND (status = @Status)



but in report preview it tell me i must enter intrevalDate ?

View 8 Replies View Related

How Can I Make This...

Apr 5, 2006

Hi have have this problem, I have a table called PABX that has all the callings registry and what I need to do is for each client(PABX.cod_client) I have 2 types of calls (VC1, VC2) , and for these types I need to select all the registries chaging the dialed number(PABX.NRTELEFONE) for the new one (TROCAR.NRTELEFONE) and for those client that doesn't need to change select the PABX.NRTELEFONE

is it possible through SQL Server 2000(via stored procedure) or I'll need to do it by my application using a vector ?

Thanks

View 4 Replies View Related

How To Make Class

Jan 25, 2008

hiiiiiiiiii    I am creating a web application using vb.net  in which i m using the concept of classes. now i am done all the code for inserting the values in the database using the class but it is difficult to fetch the values from the database using select command and sending them to a WebForm  . i want to know how i send send the values coming from the select command to a datagrid or another web controlif possible provide me a sample code  thanks for your help

View 2 Replies View Related

How Can I Make Checkbox

Feb 2, 2006

hello all i have a 2 questions hope that u can help me my first question is: in ms access there was a data type named yes/no and it was a checkbox is there a checkbox data type in sql server 2005? 
my second question is i need the connection code between asp.net 2005 and sql server 2005 i searched in here for that code but i got more confuse i found two codes and both are not working so hope u can give me the right connecting code. that's all thanks

View 11 Replies View Related

How To Make A Certain Log During SP Execution?

Sep 28, 2001

hi all,
Now i want to log some information (e.g.time,count...)during SP execution,how can i do it in Sql?
Thanks

View 1 Replies View Related

Make SQL Available Online

Sep 28, 2005

Can anyone tell me how I would go about making my SQL server accessable from the Internet, or know of any good tutorials to get me started, I haven't had much luck looking on google.

I need to access an SQL database from one server on another server for a web application.

Thanks

View 4 Replies View Related

Need To Make This Query

Jun 28, 2004

Hi guys, I have a car_race table which has these fields

car_id int
race_id int
b_car_won varchar // can have 'y' or 'n'

I need to know if the car lost the 1st race but won the next race

And example of that table for car_id 1:

car_id 1
race_id 1
b_car_won 'NO'

car_id 1
race_id 2
b_car_won 'YES'

Now this is the tricky part, the database has some data integrity issues, so this can occur:

car_id 1
race_id 1
b_car_won 'NO'

car_id 1
race_id 3
b_car_won 'YES'

So I cant used a fixed race_id value, need to use the race_id > 1 to know whats the next race. But this raises another issue if I have this in the database:

car_id 1
race_id 1
b_car_won 'NO'

car_id 1
race_id 3
b_car_won 'YES'

car_id 1
race_id 4
b_car_won 'YES'

If I query I'd get 2 rows where race_id > 1. And I only need the first one, because 3 is the next race.

I need to fetch in a single row if possible, the result of the 1st race and the 2nd race. How can I do this?

View 11 Replies View Related

How Do I Make It Use My Index?

Dec 15, 2004

Hello!

I have two tables

users and pictures.

table users have a clustered (PK) index on userid
table pictures have a clustered (PK) index on userid

when I do this query:

"select userid from pictures where userid=123"

then It will do a clustered index seek

But If I do any of those:

"select t2.userid from users t1 left join t2 on t1.userid = t2.userid"
or
"select (select userid from pictures where usedid = t1.userid) from users t1"

It will do a clustered index scan.

How can I force it to seek my index instead of scan?

Thanks!

View 1 Replies View Related

I Want To Make Project

May 26, 2006

i want to make a database for pharmacy using sql server and VB.NET
so any body can give me illuminations


thanks in advance
george albert

View 4 Replies View Related

Any Way To Make This Shorter?

Aug 1, 2006

I have a T-SQL query that is used to pull up some data for once-a-day export, just out of curiosity more then anything, is there a way to make this shorter?SELECT DISTINCT u.userId,u.lastName,u.firstName,u.address1,u.address2,u.city,u.state,u.zip,CASE WHEN u.UserClassID_fk BETWEEN 1 AND 3 AND COALESCE(u.RetailerNumber_fk,0)= 0 THEN 'Corporate'WHEN u.UserClassID_fk BETWEEN 1 AND 3 AND COALESCE(u.RetailerNumber_fk,0)<> 0 THEN 'RETAILER'+ CONVERT(varchar, COALESCE(u.RetailerNumber_fk,0))WHEN u.UserClassID_fk BETWEEN 4 AND 8 AND COALESCE(p.plantCode,ap.plantNumber_fk,ps.plantNum ber_fk,0) = 0THEN 'Corporate'WHEN u.UserClassID_fk BETWEEN 4 AND 8 AND COALESCE(p.plantCode,ap.plantNumber_fk,ps.plantNum ber_fk,0) <> 0THEN 'PLANT'+ CONVERT(varchar, COALESCE(p.plantCode,ap.plantNumber_fk,ps.plantNum ber_fk,0))WHEN u.UserClassID_fk BETWEEN 9 AND 14 AND COALESCE(p.regionNumber_fk,rg.regionNumber,0) = 0THEN 'Corporate'WHEN u.UserClassID_fk BETWEEN 9 AND 14 AND COALESCE(p.regionNumber_fk,rg.regionNumber,0) <> 0THEN 'REGION'+ CONVERT(varchar, COALESCE(p.regionNumber_fk,rg.regionNumber,0))END CPGkeyFROM [...] JOIN [...]I'm hoping there is something in a way of....If userClass Between 1 and 3 ThenIF COALESCE(u.RetailerNumber_fk,0)= 0 Then 'Corporate'ELSE 'RETAILER'+ CONVERT(varchar, COALESCE(u.RetailerNumber_fk,0))End IF as CPGKey,Thanks in advace.

View 1 Replies View Related

Make A Copy Of A Db

May 29, 2007

I need to restore a copy of database to a new db name

i'm trying by creating a new db and restoring by doing

RESTORE DATABASE [userr] FROM DISK = N'D:sqlbackupsuser.bak' WITH FILE = 4, NOUNLOAD, STATS = 10
GO

i'm getting an error

Msg 3154, Level 16, State 4, Line 1
The backup set holds a backup of a database other than the existing 'userr' database.
Msg 3013, Level 16, State 1, Line 1
RESTORE DATABASE is terminating abnormally.


What's the best way to do this?

View 10 Replies View Related

T-SQL (SS2K8) :: IF 0.00 Then Make It .00

Jan 28, 2015

I thought this would be somewhat easy but I'm having trouble with this one. I have a statement that if 'ACTLABCOST' or 'ACTMATCOST' has a value of 0.00 then I need to make it .00.

Here's the statement:

Select
CONVERT(VARCHAR(10), xn_approveddate, 101) + ' ' + convert(VARCHAR(8), xn_approveddate, 108)as "Approved Date",
WORKTYPE,

[Code]....

View 5 Replies View Related

How To Make @str Global?

Jan 31, 2007

If following code, it is ok if I execute part1 and q1 together.
but if I try to execute Q2, I got error

Server: Msg 137, Level 15, State 2, Line 4
Must declare the variable '@str'.

I guess I have to execute part1 and Q2 at same time.

Is there a way to avoid that. I mean after I execute part1 @str will be kept in memory, and I can execut q2 without a problem? (like in SAS)
Thank

/* Part1*/
/* how to make @str global*/
declare @str nvarchar(20);
set @str='%subway%';

/*Q1*/
select *, case regionname when 'telesales' then 't' else 'o' end as rn
from dbo.RPT_ContractDetails
where businessname like @str

/* Q2*/
select contracttypename,regionname, count(*)as cou, sum(fundingamount)as Dollar
from dbo.RPT_ContractDetails
where businessname like @str
group by contracttypename,regionname

View 3 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved