|
OK, it turns out the dest. connection string is stored in a static field, and I only set its value from the database the first time it is read. SQL Server just keeps the class loaded 'forever', so every subsequent access returns the first value.
|
|
|
|
|
I wrote a stored procedure that looks like this.
CREATE PROCEDURE dbo.TEST
(
@Name varchar(50),
@Surname varchar(50)
)
DECLARE @ID int
INSERT INTO Table1
(
Name,
Surname
)
VALUES
(
@Name,
@Surname
)
SELECT @ID = SCOPE_IDENTITY()
The problem is that the SCOPE_IDENTITY() does not get the ID value.
Illegal Operation
Making Computer Software Talk
|
|
|
|
|
Illegal Operation wrote: SELECT @ID = SCOPE_IDENTITY()
try SET @ID = (SELECT SCOPE_IDENTITY())
|
|
|
|
|
Does the table have an identity column?
Wout Louwers
|
|
|
|
|
Illegal Operation wrote: DECLARE @ID int
Here in your stored procedure you have Declared @ID as just a local variable. If you need that value to be returned by the procedure then you have declare it as a output parameter.
DECLARE @ID int OUT
[OR]
CREATE PROCEDURE [spTest]<br />
@ID int OUT,<br />
-- Other parameters here<br />
AS<br />
-- Your Insert Query Here<br />
SELECT @ID= SCOPE_IDENTITY()<br />
GO
Regards - J O H N -
|
|
|
|
|
i was just executing an update statement like this and that error occured..
it usually runs without error.. except for this specific data..
what does that "plan dates are invalid" mean?
thanx in advance again!!
UPDATE AJ_CONTRACTS
SET EXPECTED_SIGNOFF = '06/20/2008',
CONLEN = '20',EXTENDED = 'Y',
CONLEN_UNIT = 'M',
UPDATED_BY='apagustin',
UPDATE_DATE ='10/25/2007'
WHERE (CREW_SEQ_NO = '27979')
|
|
|
|
|
I've not seen that error message before. Try:- The date formats may be incorrect. Try using '20 Jun 2008' and '25 Oct 2007' instead.
- Double-check if there are any triggers defined on the table.
If these don't identify your problem then give us the exact error message (including error numbers).
Regards
Andy
|
|
|
|
|
Try swapping the date.
06/20/2008 to 2008/06/20
Illegal Operation
Making Computer Software Talk
|
|
|
|
|
anthoy wrote: SET EXPECTED_SIGNOFF = '06/20/2008',
You can try this as well:
SET EXPECTED_SIGNOFF = cast('06/20/2008' as date)
It will force the string into a date (you will need to do the same with UPDATE_DATE).
You always pass failure on the way to success.
|
|
|
|
|
thanks for all the help guys.. i really appreciated it... my boss says its ok.. cause my data was just messed up or the field 'EXPECTED_SIGNOFF' was somewhat already filled in..
it was a 'trigger' on that table 'AJ_CONTRACTS' that was causing the error.. maybe you were all right it's just the date format.. cause i was using format date 'dd/mm/yyyy'
|
|
|
|
|
I have a stored procedure that rebuilds the indexes on a clients database.
Useing a Try Catch block I write any errors to a cursor which report any errors
when the procedure has finished running.
<br />
WHILE @@fetch_status = 0<br />
BEGIN<br />
SET @SQL = 'ALTER TABLE '+@TableName+' ADD CONSTRAINT '+@ObjectName+' '+@Fields<br />
BEGIN TRY<br />
EXEC (@SQL)<br />
END TRY<br />
BEGIN CATCH<br />
INSERT INTO ##NonCreate VALUES(' constraint ' + @ObjectName + ' on table ' + @TableName, ERROR_MESSAGE())<br />
END CATCH<br />
END<br />
FETCH NEXT FROM cUniqueConstraintList INTO @TableName, @ObjectName, @Fields<br />
<br />
The stored proceudre works fine and output any errors to the log.
However the message reported by ERROR_MESSAGE() is a bit less than
informative. "Could not create constraint. See previous errors."
Msg 2714, Level 16, State 4, Line 1
There is already an object named 'my_constraint_name' in the database.
Msg 1750, Level 16, State 0, Line 1
Could not create constraint. See previous errors.
My error log is given the Msg 1750 error, I would prefer it gave me the 2714 message, as this is more informative as to why the error has occured.
Does any one know of any way of returning the first message, or point
me in the right direction?
|
|
|
|
|
Hi...
You can get all the info regarding the error....
for more info click Here[^]
Regards,
Sandeep Kumar.V
|
|
|
|
|
One of the first places I referenced.
That example works as the Div by 0 only returns one error message and ERROR_MESSAGE() returns the last error message. But when an error occurs on a Add/Drop table constraint 2 errors occur, and I'm interested in the first message and not the last!
|
|
|
|
|
Hi
I have a table named StudentResult
UserID School Semester Grade Campus Status
1 School1 Summer 10 Campus1 Accepted
2 School1 Summer 10 Campus1 Accepted
3 School1 Summer 10 Campus1 Rejected
4 School1 Summer 10 Campus1 Rejected
5 School1 FALL 10 Campus1 Accepted
6 School1 Summer 12 Campus1 Accepted
7 School1 Summer 12 Campus1 Rejected
8 School1 Summer 12 Campus1 Accepted
9 School1 Summer 12 Campus1 Rejected
10 School1 Summer 12 Campus1 Accepted
11 School1 FALL 12 Campus1 Rejected
12 School1 FALL 12 Campus1 Accepted
13 School1 FALL 11 Campus1 Rejected
14 School1 FALL 11 Campus1 Accepted
15 School1 FALL 11 Campus1 Accepted
16 School1 Summer 11 Campus1 Rejected
17 School1 Summer 11 Campus1 Accepted
18 School1 Summer 11 Campus1 Accepted
I want to take the number of accepted and rejected users from the above table as the result table below.I want to consider grade,Campus and semester for taking count and the result should be like result table.Please help me to write Query for this.
I am using SQL server2000. as database
School Semester Grade Campus NoofAccepted NoofRejected
School1 Summer 10 Campus1 2 2
School1 Fall 10 Campus1 1 0
School1 Summer 11 Campus1 2 1
School1 Fall 11 Campus1 2 1
School1 Summer 12 Campus1 3 2
School1 Fall 12 Campus1 1 1
Thanx
|
|
|
|
|
select School, Semester, Grade, Campus,
sum(CASE WHEN Status = 'Accepted' THEN 1 ELSE 0 END) AS NumOfAccepted,
sum(CASE WHEN Status = 'Rejected' THEN 1 ELSE 0 END) AS NumOfRejected
from StudentResult
group by School, Semester, Grade, Campus
Of course, this is what you have asked for, but not necessarily the best way of going about it... you could always just use count (*) and use the Status as a Column heading also...
-------------------------------------------
Don't walk in front of me, I may not follow;
Don't walk behind me, I may not lead;
Just bugger off and leave me alone!!
|
|
|
|
|
hihi,i'm new baby in sql.So, I would like ask someone can help me solve a question as posted as below.
1. As a admin, i need to know who is connecting to my sql database.But,I have no idea to get the method to detect who is connecting to my sql database
thank for your help
|
|
|
|
|
Running sp_who2 will give necessary details
|
|
|
|
|
thank for your helping.
But, can you explain more detail about 'sp_who2'.
I really have no idea to 'sp_who2'.
Thank again
|
|
|
|
|
|
select [name] from sysusers where [name] <> 'dbo' and islogin = 1
Regards - J O H N -
|
|
|
|
|
thank for help.I can solve my problem.thank again.
|
|
|
|
|
I want to update table, with this following code:
declare @parentid int<br />
select accountparentid=@parentid from account where accountid=@accountid<br />
<br />
while @parentid<> 0<br />
begin<br />
UPDATE [dbo].[account]<br />
SET [accountvalue] = [accountvalue]+@accountvalue<br />
where accountid=@parentid<br />
select accountparentid=@parentid from account where accountid=@parentid<br />
END
How do I create the function in SQL with the name UpdateAccountParent, I'm using C# express. This should be easy. Thanks.
|
|
|
|
|
consult MSDN[^]
Tirtha
Do not go where the path may lead, go instead where there is no path and leave a trail.
Author: Ralph Waldo Emerson (1803-82), American writer, philosopher, poet, essayist
|
|
|
|
|
Hi My name is Lee Hatcher and I am a newbie to Access and sql. This has probally already been asked but I am trying to create round control buttons for them. Any help will be appreciated.
Thanks,
Lee
|
|
|
|
|
Round buttons for sql??
What are you doing?
|
|
|
|