|
won't you get a lot of service calls any time you add a table or a field, making it all fail suddenly?
|
|
|
|
|
As there is a fundamental problem with change management I think that would be the least of his problems. It sounds like he does not own the database and he is not in the change management loop.
We recently had something like this where the IT team changed a view that was feeding us and did not inform the clients of the view. A rocket went around the IT team and we are now in the CM loop.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
|
Hello
can any one please tell me how can i perform the following actin in SQL
if ((sizee == "") && (sidee == "") && (color == ""))
{
ItemComputerCode = PartGroup + "-" + Model + "-" + Brand + "-" + orgnShortName;
}
else if ((sizee == "") && (sidee == "") && (color != ""))
{
ItemComputerCode = PartGroup + "-" + Model + "-" + Brand + "-" + color + "-" + orgnShortName;
}
else if ((sizee == "") && (sidee != "") && (color == ""))
{
ItemComputerCode = PartGroup + "-" + Model + "-" + Brand + "-" + sidee + "-" + orgnShortName;
}
else if ((sizee == "") && (sidee != "") && (color != ""))
{
ItemComputerCode = PartGroup + "-" + Model + "-" + Brand + "-" + sidee + "*" + color + "-" + orgnShortName;
}
else if ((sizee != "") && (sidee == "") && (color == ""))
{
ItemComputerCode = PartGroup + "-" + Model + "-" + Brand + "-" + sizee + "-" + orgnShortName + "*";
}
else if ((sizee != "") && (sidee == "") && (color != ""))
{
ItemComputerCode = PartGroup + "-" + Model + "-" + Brand + "-" + sizee + "*" + color + "-" + orgnShortName;
}
else if ((sizee != "") && (sidee != "") && (color == ""))
{
ItemComputerCode = PartGroup + "-" + Model + "-" + Brand + "-" + sizee + "*" + sidee + "-" + orgnShortName;
}
else
{
ItemComputerCode = PartGroup + "-" + Model + "-" + Brand + "-" + sizee + "*" + sidee + "*" + color + "-" + orgnShortName;
}
return ItemComputerCode;
thnx in advance
Regards
|
|
|
|
|
It would likely involve case , but I wouldn't do it in SQL, just clean up the code you have.
System.Text.StringBuilder sb = new System.Text.StringBuilder() ;
sb.Append ( PartGroup ) ;
sb.Append ( "-" + Model ) ;
sb.Append ( "-" + Brand ) ;
string sep = "-"
if (sizee != "") { sbAppend ( sep + sizee ) ; sep = "*" ; }
if (sidee != "") { sbAppend ( sep + sidee ) ; sep = "*" ; }
if (color != "") { sbAppend ( sep + color ) ; sep = "*" ; }
sb.Append ( "-" + orgnShortName ) ;
return ( sb.ToString() ) ;
|
|
|
|
|
thnx,but if ay one plz do it in sql
|
|
|
|
|
Hi, I am running VS2008 and use SQLExpress. I craete a SP in my database. then when I wanna save it I will get this error : Cannot update identity column 'Code'
the above code is my SP
Create PROCEDURE dbo.SprocInsertUpdatePerson
(
@code int,
@id int,
@name nvarchar(50),
@passportNumber nvarchar(50),
@nationality nvarchar(50),
@created datetime,
@creator nvarchar(50)
)
AS
Declare @ReturnValue int
if (@Code IS NULL) --New Item
Begin
insert into Person
(
Code,
Id,
Name,
PassportNumber,
Nationality,
Created,
Creator
)
values
(
@code,
@id,
@name,
@passportNumber,
@nationality,
@created,
@creator
)
Select @ReturnValue = Scope_Identity()
End
else
Begin --Update Item
Update Person
Set Code = @code,
Id = @id,
Name = @name,
PassportNumber = @passportNumber,
Nationality = @nationality,
Created = @created,
Creator = @creator
where Id = @id
Select @ReturnValue = @Id
End
IF (@@ERROR != 0)
BEGIN
RETURN -1
END
ELSE
BEGIN
RETURN @ReturnValue
END
I really appreciate if someone help me.
thx a lot
|
|
|
|
|
You can remove it from the insert-statement; an IDENTITY [^] is automatically generated when a new record is inserted. Kinda like an autonumber-column in Microsoft Access. The Scope_Identity would then return that newly generated value.
I are Troll
|
|
|
|
|
The error message has told you the problem: you cannot update teh identity column. Values for this column are automatically set by the database engine when you add a new record. They are read-only after that, as a unique identifier for that row. So you should not try to set the ID when updating records, just use it in the WHERE clause to specify which row to update.
|
|
|
|
|
Have you tried
SET IDENTITY_INSERT table ON
I use it when migrating data from an old database into an empty database.
But normally, IDENTITY should be set by the database, not by your code.
|
|
|
|
|
Hi, thanks for your answer; I will get the solution in the last post.
|
|
|
|
|
I am currently doing some project and I think Im going crazy. I am developing an online video rental using JavaScript, and actually has a database on it..Can I ask aside from ASP..what should I used to make a connection string,I am using a MS Access 2007 as database?where should I put it on my HTML/JavaScript file if you can give me a hint about making a connection string? it is possible to use database with pure HTML/Javascript file aside from asp?pls help me thanks!
|
|
|
|
|
No, javascript by itself should not be used to connect to the database. Generally, javascript will make an ajax request to ASP which will connect to the DB and return results to javascript.
|
|
|
|
|
One can easily view the source of the HTML pages, and that would expose the connectionstring to the outside world. Hence, it'd be better safer to use a server-side language to access the database.
I are Troll
|
|
|
|
|
I see so there is no other way to connect it is by ASP/ASP.NET/ADO/AJAX?am I right?so if I used some of this language my file extension should be .asp..instead of .html or .js?if I used ADO?
|
|
|
|
|
ASP is the older serverside scriptlanguage
ASP.NET is the newer version
ADO is what's used to talk to the database
AJAX is used to have the client call some serverside function
Do you have a webserver that's capable of running ASP.NET pages? You can verify by executing a small test-aspx
I are Troll
|
|
|
|
|
Dear all,
I want to know that can I drop temp table from different server?
tables are existed in Server1
but, I will create storeprocedure to drop these table from Server2
if (exists(SELECT 1 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE='BASE TABLE' AND TABLE_NAME = 'TEMP1'))
begin
Drop TABLE .dbo.TEMP1
end
my problem is I can't pass the servername(Server1) to check if temp tabels are exist or not.
Pls,Is there anyway to drop table from different server?
Thank you.
|
|
|
|
|
DROP TABLE FROM LinkedServer.YourDB.dbo.#TableName
Hope it helps you.
I Love T-SQL
"Don't torture yourself,let the life to do it for you."
If my post helps you kindly save my time by voting my post.
www.aktualiteti.com
|
|
|
|
|
thank you for your help.
but, got error like this
The object name 'server1.dbname1.dbo.' contains more than the maximum number of prefixes. The maximum is 2.
and the other fact is I have to check if table is exist or not.
if I select from Information.schema I can't put server name before Information.Schema
SELECT 1 FROM INFORMATION_SCHEMA.TABLES
SELECT 1 FROM servername.dbname.INFORMATION_SCHEMA.TABLES (this code not work)
|
|
|
|
|
You have to create linked[^], then you can try to delete temp table
I Love T-SQL
"Don't torture yourself,let the life to do it for you."
If my post helps you kindly save my time by voting my post.
www.aktualiteti.com
|
|
|
|
|
Yah, already link
even I can select from it, but not delete.
|
|
|
|
|
naunt wrote: even I can select from it, but not delete.
The DELETE and the SELECT statement require the same prefixes when referring to a linked server. Did you get the same error when executing the delete, or a different one?
Can you post both the command and the error-message?
I are Troll
|
|
|
|
|
Hi! Eddy Vluggen,
sorry I mean I can't drop. Delete is work fine.
select & delete work fine.
select * from [linkserver].dbname1.dbo.test
delete [linkserver].dbname1.dbo.test where field1='yyyy'
but, not for drop
DROP TABLE [linkserver].dbname1.dbo.test
got err --> The object name 'linkserver.dbname1.dbo.test' contains more than the maximum number of prefixes. The maximum is 2.
|
|
|
|
|
|
Seems that you can't directly drop a remote table then. How about creating a sproc in the remote database that takes a tablename and drops it? Could that be called with the three prefixes?
I are Troll
|
|
|
|