@@ERROR Logic Not Working

Jul 5, 2006

Hi There

I am having a little trouble with something very simple:

I have a stored procedure with the following sql in it:

UPDATE mfsWS_CustNewCustomer SET Result_Id = 0 WHERE QueryGUID = @Guid

IF (@@ERROR <> 0)

BEGIN

RAISERROR ('Error setting Result_Id', 16, 1)

UPDATE mfsWS_CustNewCustomer SET Result_Id = 1 WHERE QueryGUID = @Guid

RETURN

END

To test if this works i SET the Result_Id = 'X' this is a smallint column so this should not work.

My issue is that all i get is the error:

cannot convert char to numeric etc etc

However the @@ERROR logic is not executed , my error is not raised and the update does nto happen, it si as though the entire sp aborts at the point where i try do the bogus update.

Is there something i should SET at the beginning of my sp or something ? How do i ensure that any error will be passed to the logic that checks @@ERROR and performs the appropriate actions ? This is SS2000, so i cannot use try catch.

Thanx

View 10 Replies


ADVERTISEMENT

Query Logic Not Working...

Sep 14, 2006

I have a little system of 3 tables Job, employees and times. This times table has the fields times_id, employee_id and job_idI'm trying to have a query that pull of employees that don't have a certain job_id yet. I'm going to put this data in a table so the user knows they are available for that job. The code i have isn't working, and i'm not sure why.SELECT DISTINCT times.employee_id, employee.employee_nameFROM employee INNER JOIN times ON employee.employee_id = times.employee_id WHERE (times.job_id <> @job_id)  Thanks in advance for any help. I'm sure I missing someting silly, or maybe i need to have a stored procedure involved?... Thanks!

View 3 Replies View Related

Transact SQL :: Creating Comma Separated Value Logic Not Working Inside Function?

Jul 16, 2015

I am need to create comma separated list in sql and I am using below query.

declare @ConcatenatedString NVARCHAR(MAX)
select @ConcatenatedString = COALESCE(@ConcatenatedString + ', ', '') + CAST(rslt.Number AS NVARCHAR)
from
(
select 1 Number
union
select 2 Number
union
select 3 Number
)rslt
select @ConcatenatedString

When I use the above code inside a function, i am not getting desired output.

create function GetConcatenatedValue
AS
(
declare @ConcatenatedString NVARCHAR(MAX)
select @ConcatenatedString = COALESCE(@ConcatenatedString + ', ', '') + CAST(rslt.Number AS NVARCHAR)
from
(
select 1 Number
union
select 2 Number
union
select 3 Number
)rslt
return @ConcatenatedString
)

View 3 Replies View Related

Logic Error

Jul 20, 2005

Declare @mx intSet @mx = (select max(score)from ,,,where ,,,,andsubstring(city,1,1)='g')select score,@mxfrom ,,,,where ,,,, andsubstring(city,1,1)='g')group by scoregothis seems to work for small tablesbut when table is big and substring(city,1,1)='g')condition is not met it takes aweful time like goesin an infinit loop.--Sent by 3 from yahoo part of comThis is a spam protected message. Please answer with reference header.Posted via http://www.usenet-replayer.com

View 1 Replies View Related

Error Output Logic

Apr 10, 2007

Hello,

I have a simple SSIS package running under SQL 2005 SP2a.

In the data flow, I have several lookup transforms with error outputs. Each error output links to its own audit transform and then writes data to its own flat file destination.

After the data flow is complete, my control flow will then use a ForEach file container to mail the flat files to the source system data owners with a message about incomplete/inconsistent source data. I am effectively providing feedback to the source owners so that we may improve the quality of data that gets sent to us.

My problem is that the flat file (which contains the offending rows) seems to get created everytime even when there were no errors in the lookup in question. Thus my ForEach container will always send a mail to the data source teams even if there were no errors as the error flat file will always exist albeit empty.

How can I stop this happening? How can I only create flat files when there really were errors? How can I prevent the source teams from receiving feedback emails when there is no reason to?

Thanks in advance
MGale1

View 1 Replies View Related

Error With Flow Logic When Creating A JOB

Jul 20, 2005

I have a sql server automatic job set up containing 2 steps.First step is an Operating System Command (CmdExec) type job whichruns a .bat file which copies across a backup file to this machine.The second step is a Transact -SQL Script (TSQL) type job which runsthe RESTORE DATABASE REPLACE command which restores the backup filecopied across in step 1.Step 1's advanced option says: On Success Action: Goto Step [2]Restore the database.Step 2's advanced option says: On Success Action: Quit the jobreporting success.On clicking ok I receive the error message:"WARNING: The following job step(s) cannot be reached with currentflow logic: [1] Transfer the Backup File. Are you sure this is whatyou want".The job fails to run.Both steps do run successfully when set up as two separate jobs - notlike this which has the two steps in one job.Anyone have any ideas as to what the flow logic problem is?Thiko!

View 2 Replies View Related

Logic Consistency-based I/o Error. Dbcc Checkdb

Nov 27, 2007

every few days i'm getting an error in the application log , eventID 824, saying 'SQL Server detected a logical consistency-based i/o error; incorrect checksum. it then recommends completing a full database consistency check (dbcc checkdb).

i have run the dbcc checkdb ('databasename') and it is returning an error msg of:

Msg 8697, Level 16, State 215, Line 1
An internal error occurred in DBCC which prevented further processing
Msg 8921, Level 16, State 1, Line 1
Check terminated. A failure was detected while collecting facts. Possibly tempdb out of space or a system table is inconsistent. Check previous errors

i have oodles of disk space left. any ideas on where to go from here.

thank you for any help,
-Mark

View 3 Replies View Related

SQL Server 2012 :: Error Creating Temp Table Based On IF Logic

Nov 13, 2014

I could deploy across my environment, which is a mix of 2008R2/2012 servers, to give some information on log files. Running into a silly issue right off the bat. The table that DBCC LogInfo() conjures out of magic is different between the two. In 2012 it gained the RecoveryUnitID column. So I'm trying to write some logic to create a temp table based on which version is running. I would like to avoid a global temp table if possible. Here's what I've tried:

sp_executesql creates a table outside of the scope of my session:
DECLARE @PrVers NVARCHAR(128)
, @PrVersNum DECIMAL(10,2)
, @StageTable NVARCHAR(1024) = N''

[code]....

View 9 Replies View Related

Working Since Morning, Simple Error But Unable To Resolve, ERROR : 26 , Please Help

Dec 15, 2006

dear friends,
 i started using Asp.net for developing webparts, web parts automatically connect to a database to be created and saved in the database.
i had already Sql Server 2005 Express Edition installed so my webpart page ran and automatically created the database "AspNetDb" in the "App_Data" folder.
but when i uninstalled Sql Server 2005 Express Edition and then installed the Sql Server 2005 Enterprise Edition, it gave me the following Error 26 as below :

--------------------------------------------------------- Beginning of Error Message -------------------------------------------------- 
 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)
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. SQLExpress database file auto-creation error:
The connection string specifies a local Sql Server Express instance using a database location within the applications App_Data directory. The provider attempted to automatically create the application services database because the provider determined that the database does not exist. The following configuration requirements are necessary to successfully check for existence of the application services database and automatically create the application services database:

If the applications App_Data directory does not already exist, the web server account must have read and write access to the applications directory. This is necessary because the web server account will automatically create the App_Data directory if it does not already exist.
If the applications App_Data directory already exists, the web server account only requires read and write access to the applications App_Data directory. This is necessary because the web server account will attempt to verify that the Sql Server Express database already exists within the applications App_Data directory. Revoking read access on the App_Data directory from the web server account will prevent the provider from correctly determining if the Sql Server Express database already exists. This will cause an error when the provider attempts to create a duplicate of an already existing database. Write access is required because the web server accounts credentials are used when creating the new database.
Sql Server Express must be installed on the machine.
The process identity for the web server account must have a local user profile. See the readme document for details on how to create a local user profile for both machine and domain accounts.
--------------------------------------------------------- End of Error Message -------------------------------------------------- 
then when i checked the Machine.config file, i found this....
  <connectionStrings>    <add name="LocalSqlServer" connectionString="data source=.SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|aspnetdb.mdf;User Instance=true" providerName="System.Data.SqlClient" />  </connectionStrings>
then i thought it's becoz, of the datasource thing that the Machine.Config file supports by default the default free edition of Sql Server 2005 which is the Sql Server 2005 Express Edition.
but friend in my company we use Sql Server 2005 Enterprise Edition, so can anybody pls guide me and get me out of this soup on helping me to use Sql Server 2005 Enterprise Edition by modifying either 1) Machine.Config File and/or  2) Web.Config file and/or 3) any other way, but please help i want to do this, please......
regards and thanks
Gurjit Singh 

View 2 Replies View Related

Working Set Size Error

Aug 22, 2000

Someone asked about this and I was wondering if anyone has any idea.

Thanks in advance.
>>Yesterday in my Windows NT 4.0 Event Viewer I got a message and then I went to the the SQL Server logs and did not find and errors. Microsoft's web site did not have any insite on this issue so I need your help.
>>
>>
>>Category: Kernel
>>17122:
>>initdata: Warning: could not set working size to 259200KB.
>>
>>Please help this seems to be causing some ODBC connection problems to the databases.

View 1 Replies View Related

SQL 2005 X64 Working Set Error

Apr 7, 2008

I have the same error occuring each day at the same exact time on my mirror server. I looked online, and there are tons of references online to people having this issue, but not so many with resolutions. The server is identical to its Primary server in every aspect. It has the same patches, same exact hardware, it was originally going to be a cluster until some other issues turned it into a mirror set, and the Primary doesn't have this issue, just the mirror which is why it doesn't make sense.

Everyday between 17:56:30 and 17:58:30 I get this error

Date 4/6/2008 5:57:56 PM
Log SQL Server (Current - 4/7/2008 12:00:00 AM)
Source spid1s
Message
A significant part of sql server process memory has been paged out. This may result in a performance degradation. Duration: 2361601 seconds. Working set (KB): 147436, committed (KB): 461280, memory utilization: 31%.

There is no plausible reason for this to occur on this particular server and not on the Primary which is doing all the work. I read the blog on PSS about this, as well as some of the MVP blogs. Is there anything else I can look at for this? Some of the existing references I have looked at are below.

http://msmvps.com/blogs/omar/archive/2007/09/19/a-significant-part-of-sql-server-process-memory-has-been-paged-out-this-may-result-in-performance-degradation.aspx
http://blogs.msdn.com/psssql/archive/2007/05/31/the-sql-server-working-set-message.aspx

http://support.microsoft.com/kb/918483/en-us
No matter what I do the problem persists. I gave up on this a while back since it was a mirror only, and I was busy working on other projects, but now that I have a bit of time to look at it again I am going to. Any one got any ideas?

View 8 Replies View Related

Help: SQL Error Handling Stopped Working

Jan 11, 2001

Our stored procedure error handling is not working now but did before.

When a severity level 16 (Miscellaneous user error) occurs the batch (stored procedure) exits without processing the next statement which is the error check routine. This is a simple error processing routine and used to work. What could have changed?

I have searched books online and have found nothing on abnormal termination of a SQL batch. I would appreciate some help here.

Loren

View 3 Replies View Related

Sql Error-order By Clause Not Working

Aug 27, 2007

Hi,


I have the following code and output


select distinct week ,sum(itemvalue) as itemvalue from (Select ATP,

WEEK=

CASE

WHEN (datepart(Dd, ATP) < 7 AND datename(Month,ATP)='JANUARY')

OR

( datepart(Dd, ATP) < 8 AND datename(Month,ATP)='JULY')

OR

( datepart(Dd, ATP) < 7 AND datename(Month,ATP)='OCTOBER')

THEN '1'

WHEN (datepart(Dd, ATP) < 14 AND datename(Month,ATP)='JANUARY')

OR

( datepart(Dd, ATP) < 15 AND datename(Month,ATP)='JULY')

OR

( datepart(Dd, ATP) < 14 AND datename(Month,ATP)='OCTOBER')

THEN '2'

WHEN (datepart(Dd, ATP) < 21 AND datename(Month,ATP)='JANUARY')

OR

( datepart(Dd, ATP) < 22 AND datename(Month,ATP)='JULY')

OR

( datepart(Dd, ATP) < 21 AND datename(Month,ATP)='OCTOBER')

THEN '3'

WHEN (datepart(Dd, ATP) < 28 AND datename(Month,ATP)='JANUARY')

OR

( datepart(Dd, ATP) < 29 AND datename(Month,ATP)='JULY')

OR

( datepart(Dd, ATP) < 28 AND datename(Month,ATP)='OCTOBER')

THEN '4'

WHEN ((datepart(Dd, ATP) IN (29,30,31)) AND datename(Month,ATP)='JANUARY')

OR

( (datepart(Dd, ATP) IN (29,30,31)) AND datename(Month,ATP)='JULY')

OR

( (datepart(Dd, ATP) IN (28,29,30,31)) AND datename(Month,ATP)='OCTOBER')

THEN '5'

WHEN (datepart(Dd, ATP) < 4 AND datename(Month,ATP)='FEBRUARY')

( datepart(Dd, ATP) < 5 AND datename(Month,ATP)='AUGUST')

OR

( datepart(Dd, ATP) < 4 AND datename(Month,ATP)='NOVEMBER')

THEN '5'

WHEN (datepart(Dd, ATP) <11 AND datename(Month,ATP)='FEBRUARY')

OR

( datepart(Dd, ATP) < 13 AND datename(Month,ATP)='MAY')

OR

( datepart(Dd, ATP) < 12 AND datename(Month,ATP)='AUGUST')

OR

( datepart(Dd, ATP) < 11 AND datename(Month,ATP)='NOVEMBER')

THEN '6'

WHEN (datepart(Dd, ATP) < 18 AND datename(Month,ATP)='FEBRUARY')

OR

( datepart(Dd, ATP) < 19 AND datename(Month,ATP)='AUGUST')

OR

( datepart(Dd, ATP) < 18 AND datename(Month,ATP)='NOVEMBER')

THEN '7'

WHEN (datepart(Dd, ATP) < 25 AND datename(Month,ATP)='FEBRUARY')

OR

( datepart(Dd, ATP) < 27 AND datename(Month,ATP)='MAY')

OR

( datepart(Dd, ATP) < 31 AND datename(Month,ATP)='AUGUST')

OR

( datepart(Dd, ATP) < 25 AND datename(Month,ATP)='NOVEMBER')

THEN '8'

WHEN ((datepart(Dd, ATP) IN (25,26,27,28)) AND datename(Month,ATP)='FEBRUARY')

OR

( (datepart(Dd, ATP) IN (27,28,29,30,31)) AND datename(Month,ATP)='MAY')

OR

( (datepart(Dd, ATP) IN (25,26,27,28,29,30)) AND datename(Month,ATP)='NOVEMBER')

OR

( (datepart(Dd, ATP) <2) AND datename(Month,ATP)='DECEMBER')

THEN '9'

WHEN (datepart(Dd, ATP) < 11 AND datename(Month,ATP)='MARCH')

OR

( datepart(Dd, ATP) < 9 AND datename(Month,ATP)='SEPTEMBER')

OR

( datepart(Dd, ATP) < 9 AND datename(Month,ATP)='DECEMBER')

THEN '10'

WHEN (datepart(Dd, ATP) < 18 AND datename(Month,ATP)='MARCH')

OR

( datepart(Dd, ATP) < 16 AND datename(Month,ATP)='SEPTEMBER')

OR

( datepart(Dd, ATP) < 16 AND datename(Month,ATP)='DECEMBER')

THEN '11'

WHEN (datepart(Dd, ATP) < 25 AND datename(Month,ATP)='MARCH')

OR

( datepart(Dd, ATP) < 23 AND datename(Month,ATP)='SEPTEMBER')

OR

( datepart(Dd, ATP) < 23 AND datename(Month,ATP)='DECEMBER')

THEN '12'

WHEN (datepart(Dd, ATP) > 24 AND datename(Month,ATP)='MARCH')

OR

( datepart(Dd, ATP) > 22 AND datename(Month,ATP)='SEPTEMBER')

OR

( datepart(Dd, ATP) < 30 AND datename(Month,ATP)='DECEMBER')

THEN '13'

ELSE 'BEYOND'

END , SUM(ITEMVALUE) as ITEMVALUE



FROM tOPENLINE_MODIFIED

LEFT OUTER JOIN

tZCHANNEL ON tOPENLINE_MODIFIED.ZCHANNEL = tZCHANNEL.ZCHANNEL

WHERE RequestQtr in ('Q4')

and tOPENLINE_MODIFIED.ATP >= '7/01/07'

and tOPENLINE_MODIFIED.ORDERTYPE in ('OR','ZBOS','ZECM','ZOR','ZOB','ZEXP')

and dbo.tZCHANNEL.ZCHANNEL in ('D','I','01', '02', '06', '07', '10')

and tOPENLINE_MODIFIED.ACCTASSIGNGRP in ('01','02')

AND tOPENLINE_MODIFIED.SOLD2NAME NOT LIKE ('%celestica%')

AND tOPENLINE_MODIFIED.SOLD2NAME NOT LIKE ('%giant%')

and tOPENLINE_MODIFIED.PLANT IN ('COF1', 'I405', 'I375', 'IOM4', 'IOM5', 'I316')

GROUP BY ATP)as A

GROUP BY week

output:

week itemvalue

------ ---------------------

1 1214003.60

10 9257193.45

11 12095432.11

12 11429629.08

13 7315751.08

2 1052337.53

3 951038.10

4 274769.21

5 465278.37

6 78003.67

7 607681.02

8 9042948.17

9 2255545.25

but i need the output as

week
1
2
3
4
5
6
7
8
9
10
11
12
13

iam not able to achieve this after trying so many times.Please help me on this.

Thanks,
SVGP
















View 6 Replies View Related

Error Working With DTS -- Class Not Registered

Jun 1, 2007

I have a DTS package (stored in a .dts file) that was created in SQL Server 2000 and I am trying to work with it in SQL 2005. When I try to import it into the Legacy > Data Transformation Services node in Management Studio, I get a window that reads "Class Not Registered (Microsoft Data Transformation Services (DTS) Package)". I get the same error if I try to just execute the package itself from a query window.



I have Legacy Support installed, and I also have Integration Services installed.



Any ideas? We have three installations of SQL 2005 and I am getting the same error on all of them.

View 1 Replies View Related

SQLCMD Error - Working With Variables And Synonyms

Jan 3, 2008

Hi All,

Been doing some testing with SQLCMD and variables for installation scripts, enclosed below is some source code.
The one problem, I've been getting is the following error:

Incorrect syntax near 'certification'

This has been tested only in SSMS utilising the run in SQLCMD mode.

This error only occurs on the SQLCMD variable replacement, where it replaces $(Cert_Schema) for the word Certification.
Running the CREATE Synonym with the word Certification hard-coded into the script works.

Any ideas?
Microsoft SQL Server 2005 - 9.00.3054.00 (Intel X86) Mar 23 2007 16:28:52 Copyright (c) 1988-2005 Microsoft Corporation Developer Edition on Windows NT 5.1 (Build 2600: Service Pack 2)

Best Regards,

D


USE [Testing]

GO

/****** Object: Table [certification].[Table_1] Script Date: 01/03/2008 11:22:48 ******/

SET ANSI_NULLS ON

GO

SET QUOTED_IDENTIFIER ON

GO

CREATE TABLE [certification].[Table_1](

[PKId] [smallint] NOT NULL,

[Name] [nchar](10) NULL,

CONSTRAINT [PK_Table_1] PRIMARY KEY CLUSTERED

(

[PKId] ASC

)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]

) ON [PRIMARY]

--- SQLCMD Script below:
-- line below should read, colon setvar cert_schema 'certification'

etvar Cert_Schema 'certification'
-- The line below fails to work for some reason

CREATE SYNONYM crt_asa FOR $(Cert_Schema).Table_1

DROP SYNONYM crt_asa

-- Hard-coded equivilant line works

CREATE SYNONYM crt_asa FOR certification.Table_1

DROP SYNONYM crt_asa

View 3 Replies View Related

Error In Stored Procedure While Working With Temp. Table

May 31, 2007

Creating a temporary table in stored procedure and using a sql query to insert the data in temp. table.I am facing the error as :
String or binary data would be truncated.The statement has been terminated.
The procedure i created is as :
ALTER PROCEDURE fetchpersondetails
AS
CREATE Table #tempperson (personID int,FirstName nvarchar(200),LastName nvarchar(250),title nvarchar(150),Profession nvarchar(200),StreetAddress nvarchar(300),
StateAddress nvarchar(200),CityAddress nvarchar(200),CountryAddress nvarchar(200),ZipAddress nvarchar(200),Telephone nvarchar(200),Mobile nvarchar(200),
Fax nvarchar(200),Email nvarchar(250),NotesPub ntext,Affiliation nvarchar(200),Category nvarchar(200))
 
Insert into #tempperson
SELECT dbo.tblperson.personID, ISNULL(dbo.tblperson.fName, N'') + ' ' + ISNULL(dbo.tblperson.mName, N'') AS FirstName, dbo.tblperson.lname AS LastName,
dbo.tblperson.honor AS Title, dbo.tblperson.title AS Profession, dbo.tblperson.street + ' ' + ISNULL(dbo.tblperson.suite, N'') AS StreetAddress,
dbo.tblperson.city AS cityaddress, dbo.tblperson.state AS stateaddress, dbo.tblperson.postalCode AS zipaddress,
dbo.tblperson.Phone1 + ',' + ISNULL(dbo.tblperson.Phone2, N'') + ',' + ISNULL(dbo.tblperson.Phone3, N'') AS Telephone,
dbo.tblperson.mobilePhone AS mobile, dbo.tblperson.officeFax + ',' + ISNULL(dbo.tblperson.altOfficeFax, N'') + ',' + ISNULL(dbo.tblperson.altOfficeFax2,
N'') AS Fax, ISNULL(dbo.tblperson.Email1, N'') + ',' + ISNULL(dbo.tblperson.Email2, N'') + ',' + ISNULL(dbo.tblperson.Email3, N'') AS Email,
dbo.tblperson.notes AS NotesPub, dbo.tblOrganizations.orgName AS Affiliation, dbo.tblOrganizations.orgCategory AS Category,
dbo.tblCountry.countryNameFull AS countryaddress
FROM dbo.tblperson INNER JOIN
dbo.tblOrganizations ON dbo.tblperson.orgID = dbo.tblOrganizations.orgID INNER JOIN
dbo.tblCountry ON dbo.tblperson.countryCode = dbo.tblCountry.ISOCode
 
please let me know the solurion of this error. 
 

View 2 Replies View Related

'Too Many Characters' Error In Sql String - Working In SQL Management Studio But Not In Code Behind???

Jan 26, 2008

Hello i constructed the following query in SQL management studio and it runs fine, exactly how i want it to. However when i run it in my code behind i get the error: 'Too many characters in character literal'
I desperatly need to use this query exactly how it displays in the mangement tool - why wont it work the same in my code behind?
(I am using c# in my code behind and binding the results of the query to a gridview)
Regards
"SELECT DISTINCT (dbo.AuthorList(publicationID))+ ';' + ISNULL(' Editor: '+Publication.editor, '')+ '' + ISNULL(' "'+Publication.title+'"', '')+ '' + ISNULL(' Book: "'+Publication.booktitle+'"', '')+ '' + ISNULL(' '+Publication.type, '')+ '' + ISNULL(' '+Publication.journal, '')+ '' + ISNULL(' Series: '+Publication.series+'.', '')+ '' + ISNULL(' '+Publication.school, '')+ '' + ISNULL(' '+Publication.institution, '')+ '' + ISNULL(' '+Publication.organisation, '')+ '' + ISNULL(' '+Publication.month, '')+ '' + ISNULL(' ('+convert(nvarchar, Publication.year)+')', '')+ '' + ISNULL(' '+Publication.publisher, '')+ '' + ISNULL(' '+Publication.address+'.', '')+ '' + ISNULL(' '+Publication.howpublished, '')+ '' + ISNULL(' Ed: '+convert(nvarchar, Publication.edition)+'.', '')+ '' + ISNULL(' '+Publication.note, '')+ '' + ISNULL(' Vol:'+Publication.volume+'.', '')+ '' + ISNULL(' No:'+Publication.number+'.', '')+ '' + ISNULL(' Pages:'+Publication.pages+'.', '')+ '' + ISNULL(' Chapter:'+Publication.chapter+'.', '') AS SingleColumn, Publication.publicationID FROM Publication;"
 
 

View 1 Replies View Related

Some Things Not Working In 2005 And Working In 2000

Mar 3, 2006

hi

I had a view in which I did something like this
isnull(fld,val) as 'alias'

when I assign a value to this in the client (vb 6.0) it works ok in sql2000 but fails in 2005.
When I change the query to fld as 'alias' then it works ok in sql 2005 .
why ?? I still have sql 2000 (8.0) compatability.

Also some queries which are pretty badly written run on sql 2000 but dont run at all in sql 2005 ???

any clues or answers ?? it is some configuration issue ?

Thanks in advance.

View 5 Replies View Related

Need Some Logic Help

May 10, 2008

Can anyone see where my logic may have gone a stray?
A user would be attempting to update a gridview row, I'm storing the amount of an item and the qty they purchased. If the order was for $150 and the grid has two item 1 x $50 and 2 x $50 the order already totals $150, so if the user tries to change the first item to a qty of 2 x $50 the total would be $200 and this would be more than the total payment or $150.
I want to then tell them they cannot do this.
@AP_ID Int,@AI_ID int,@PurchaseAmount money,@PurchaseQTY int,@LastUpdate datetime,@LastUpdateBy nvarchar(50),@Receipt_ID intASdeclare @current_item_total decimal(18,2)declare @new_item_total decimal(18,2)declare @total_payments decimal(18,2)declare @current_purchase table(receipt_id int,purchase_amt money)INSERT INTO @current_purchase SELECT  tblPurchase.Receipt_ID,(tblPurchase.PurchaseAmount * tblPurchase.PurchaseQty) as purchase_amtFROM         tblPurchase INNER JOIN                      tblReceipts ON tblPurchase.Receipt_ID = tblReceipts.Receipt_IDWHERE tblReceipts.Receipt_ID=@receipt_id--Get total already saved to recordselect @current_item_total = sum(purchase_amt) from @current_purchase--Get total amount of payment saved to recordselect @total_payments = sum(tblReceipts.AmountPaid) from tblReceipts where tblReceipts.receipt_id=@receipt_id--Get total amount user is trying to save to recordset @new_item_total = (@PurchaseAmount * @PurchaseQTY)--If current total plus new total is greater than total payment, tell user they cannot do this.IF ((@current_item_total + @new_item_total) > @total_payments)BEGINSELECT 'You are attempting to add more than your total payment.' AS MESSAGEENDELSEBEGIN--UPDATE ROWUPDATE tblPurchase SET [AI_ID]=@AI_ID,[PurchaseAmount]=@PurchaseAmount,PurchaseQTY=@PurchaseQTY,LastUpdate=@LastUpdate,LastUpdateBy=@LastUpdateBy WHERE [AP_ID]=@AP_ID SELECT 'Item was updated.' AS MESSAGEEND 

View 2 Replies View Related

Need Some Logic Help

Jan 6, 2004

Trying to bind some data to a datalist for a report.

User selects an Industry from a dropdown list and then I dump all records for that industry. However in order to parse some of the record field values into names (I.E. from a 1 to the actual company name) for some records I have to read TABLE_ONE and for other records I might have to read TABLE_TWO depending on the value of FIELD_ONE.

If FIELD_ONE = "A" then I get the NAME from TABLE_ONE.
If FIELD_ONE = "B" then I get the NAME from TABLE_TWO.
If FIELD_ONE = "C" then I get the NAME from TABLE_THREE.

I'm lost at how to get started on this. I thought about adding IF statements to my query but these won't work because I'm not passing in the value of FIELD_ONE ahead of time - it's part of the query. So I thought maybe I could do a pre-read and store all FIELD_ONE values in an ArrayList and pass these in as parameters, but the stored proc is only being called once - so that won't work.

Any thoughts on how I can do this?

View 2 Replies View Related

Help With Logic...

Apr 27, 2006

tbl_one hv 8mil rows, tbl_2 have 8k rows...

if
select count(*) from tbl_one
where sub_col1 = 2

return 3mil rows

and

select count(*) from tbl_2
where ad_col1 = '000009'

return 4k rows

HOW COME..
select count(*) from tbl_one,tbl_2
where (sub_col1 = 2 and ad_col1 = '1234')

return more than 12 billion rowss?? helpp..

View 7 Replies View Related

Help The Logic

May 3, 2006

I have to write trigger to relate two table.

If I have made changes like insert, update and modify in one table1 automatically have to change the table2 and vice versa.

How this can be done, do we need to point the common key fields in both table while inserting

View 8 Replies View Related

Is This Right Logic

Jun 12, 2007

What i'm trying to do is if this column dt.IN_DIV_NO is populated take that value first if it's null than rr.AIQ_R_DIVISION_NO and if that column is null than rr.F_DIVISION_NO.

This is what i came up with, will it evaluate the way i need it to?

case When dt.IN_DIV_NO is not null then dt.IN_DIV_NO else case when rr.AIQ_R_DIVISION_NO is null then rr.F_DIVISION_NO end end as Current_DIV

Thank-you

View 4 Replies View Related

SQL Logic

Mar 13, 2008

I have a logic problem,

I am selecting from a table

Select * from TAB_A
where state not in (1,4)
and create_date < '2008-01-01'
and
(
(x != 2 and y != 1 and z != 4) or
(x != 6 and y != 3 and z != 1) or
(x != 8 and y != 0 and z != 9)
)


then for example i am getting results where x,y and z is equal to one
or more of above combinations ?

Now i vaguely remember that using or with a != messes up the logic ?
if so can i use an NOR ? does it exist ?

View 5 Replies View Related

Logic To Use

Mar 25, 2008



I am looking for the best approach to update a table's column based on the results of two other different tables. My tables structure is as follows.


Table 1 has columns A and B (tblemployee has location and employeenumber )
Table 2 has columns C and A (tblocation has locationID (identity) and location)
Table 3 has coumns C and B (tblcountry locationID (foreign key) and employeenumber.)

I want to update Table 3 (tblcountry) with the new locationID if and employee changes location or gets miscoded using an SSIS package.

Thanks in advance.

View 7 Replies View Related

Logic

Nov 14, 2007

I am having a little problem with my logic.
i have a table simplehoursassignment that has a field named br.
i need to get the value from simplehoursassigment & say if @mybit AND br > 0
set each day.




--CREATE PROCEDURE rpt_siteMealList(

-- (@cmb1 AS VARCHAR(100)) WITH ENCRYPTION

--)

--

--AS

DECLARE @dtm1 AS DATETIME

DECLARE @mybit AS INTEGER

SET @mybit=10

SELECT @mybit = CASE datepart(dw,@dtm1)

WHEN 1 THEN 1 -- 'Sunday'

WHEN 2 THEN 2 -- 'Monday'

WHEN 3 THEN 4 -- 'Tuesday'

WHEN 4 THEN 8 -- 'Wednesday'

WHEN 5 THEN 16 -- 'Thursday'

WHEN 6 THEN 32 -- 'Friday'

WHEN 7 THEN 64 -- 'Saturday'

END

SELECT br FROM simplehoursassignment

IF @mybit AND br > 0

BEGIN

CASE WHEN @mybit = 1 THEN 'Sunday'

WHEN @mybit = 2 THEN 'Monday'

WHEN @mybit = 3 THEN 'Tuesday'

WHEN @mybit = 4 THEN 'Wednesday'

WHEN @mybit = 5 THEN 'Thursday'

WHEN @mybit = 6 THEN 'Friday'

WHEN @mybit = 7 THEN 'Saturday'

END

END

View 3 Replies View Related

Logic In T-SQL

Apr 30, 2008

I have this query that is returning the same result twice and i cannot find why. I only have one record in Subquote.
Does anyone know what the problem is?




Code Snippet
SELECT s.*
FROM Quote q
INNER JOIN SubQuote s
ON q.id = s.quoteID
INNER JOIN TakeOffSheetItem t
ON t.quoteID_takeoffitem = q.id AND t.subQuoteID_takeoffitem = s.subquoteid
INNER JOIN PipeGroup p
ON p.quoteID_PipeGroup = q.id AND p.subQuoteID_PipeGroup = s.subQuoteID
WHERE (q.id = 1
AND q.deleted = 0
AND s.deleted = 0
AND t.deleted_takeoffitem = 0
AND p.deleted_PipeGroup = 0)
ORDER BY s.subquoteid






Thanks

K

View 4 Replies View Related

ExecuteNonQuery - Add Working/Update Not Working

Jan 7, 2004

I am writing a pgm that attaches to a SQL Server database. I have an Add stored procedure and an Update stored procedure. The two are almost identical, except for a couple parameters. However, the Add function works and the Update does not. Can anyone see why? I can't seem to find what the problem is...

This was my test:


Dim cmd As New SqlCommand("pContact_Update", cn)
'Dim cmd As New SqlCommand("pContact_Add", cn)

Try
cmd.CommandType = CommandType.StoredProcedure

cmd.Parameters.Add("@UserId", SqlDbType.VarChar).Value = UserId
cmd.Parameters.Add("@FirstName", SqlDbType.VarChar).Value = TextBox1.Text
[...etc more parameters...]
cmd.Parameters.Add("@Id", SqlDbType.VarChar).Value = ContactId

cn.Open()
cmd.ExecuteNonQuery()

Label1.Text = "done"
cn.Close()

Catch ex As Exception
Label1.Text = ex.Message
End Try


When I use the Add procedure, a record is added correctly and I receive the "done" message. When I use the Update procedure, the record is not updated, but I still receive the "done" message.

I have looked at the stored procedures and the syntax is correct according to SQL Server.

Please I would appreciate any advice...

View 2 Replies View Related

Database Logic

Jul 31, 2006

I am trying to figure out how to set up this database.
Basically, there are products with their associated fields. Each product can belong to multiple categories, and each category also has subcategories.So far I have the following, but not sure if this is the best way to set it up...TABLE Products:product_id (int) (1-many relationship to product_id in Table Product_Category)sku (int)descriptionpriceTABLE Categorycategory_id (int) (1-many relationship to category_id in Table Product_Category)nameTABLE SubCategorysubcategory_id (int) (1-many relationship to subcategory_id in Table Product_Category)category_id (int)nameTABLE Product_Categoryprodcat_id (int) product_id (int) (many-1 relationship to product_id in Table Products)category_id (int) (many-1 relationship to category_id in Table Category)subcategory_id (int) (many-1 relationship to subcategory_id in Table SubCategory)
Thanks,Mick

View 1 Replies View Related

Need The Logic To Get This Done Without Cursors

Mar 20, 2007

Suppose in the table below the left column is called intNumber and right column is called strItem.I want to select the rows where the intNumber number appears for the first time(the ones marked with arrows), how do I do it? 

View 4 Replies View Related

SQL Logic Problem

May 21, 2007

I'm trying to figure out how to track what messages have been read by what users in a message board program we wrote. The users are identified by an ID number and each message has a unique number.
Let's say there are 10000 users and 200,000 messages. What would be the database setup/logic to track every user as to what messages they had read or not read? Maybe I'm missing something but it does not seem to be a  trivial task.

View 2 Replies View Related

Db Logic - Can't Put It Back Together

Feb 27, 2006

Hi there!
Hope somebody got some better insight into this problem than i have. I'm struggling with some db logic.
Overview:
I have a client who is a publisher. They would like to post all their advert-size specs for each magazine to their web site. My first thought was that ill be able to build one table and populate it with the information for each magazine. I was wrong. Each magazine comes in a different size. Thus each magazine will have different advert-sizes as well.
Layout for a magazine will look something like this:
Size              Trim          Type           Bleed
Full Page      280x440     270x430       290x450
Half Page     140x220     130x210       150x230
etc...
Some mags will not have values for Half pages since they dont print half pages and others will not have specs for Bleed.
Because of this - as an easy way out I created a table per magazine. It works but i dont think its very smart.
 
Break it down!
Ok so what im trying as a solution is to have three tables. The 1st table will hold the magID and Size values (e.g Half Page). The 2nd table will also have the magID and the Trim, Type, Bleed info. The 3rd table holds magID, sizeID, specID and the actual value (140x220).
I thought that this would be better because within these three tables i can store the information for each magazine regardless of their differences. Brilliant!
 
The Problem.
The problem comes when i have to put it all back together again. I need to represent this data in a table so i can bind it to a datagrid. I have NO idea how to do this. What i THINK i need to have is some temp table created on the fly. The row names for this temp table will come from the 1st table. The column names will come from the 2nd table and the values for each field will come from the 3rd table bound by foreign keys.
I've somewhat managed to do this with INNER JOINS. But it doesn't give the desired result. I need to set row and column NAMES using tables 1 & 2 then populate the columns with table 3, then bind to a datagrid.
 
Any ideas on how i could manage this?
 
If you made it tis far through my question then thanks anyways! I hope you can help me out!
 
Ta

View 4 Replies View Related

Views Having Logic? - Please Help!!!

Oct 26, 1999

I need to create a view joining 2 tables(1st with data, 2nd is a lookup) but I need to have some
logic(IF/ ELSE,ELSE and an UPDATE).

What is the best way?

-aw

View 1 Replies View Related







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