Showing posts with label key. Show all posts
Showing posts with label key. Show all posts

Friday, March 30, 2012

i had a problem in inserting data in a table with foriegn key

i hav following 2 tables n i am able to insert data into the second table having a foriegn key

create table Customer_Details(
Customer_ID integer primary key,
Customer_First_Name varchar(75),
Customer_Last_Name varchar(75),
Address varchar(100))

create table Account_Details(
Account_No integer primary key,
Customer_ID integer foreign key references
Customer_Details(Customer_ID),
Debit float,Credit float,Balance float )hi
can u please put ur insert and also when a column is PK it cant be null. when u do not put any think then that means it also can be a null value but pk can't be null at all.

Friday, March 23, 2012

i cant delete a row

i cant delete a row on my table. when i click delete it say : "Insufficient key column information for updating or refreshing....." what can i do?The message smells like you might be using Microsoft Access to edit a table stored in Microsoft SQL, but that you don't have all of the defined key columns in the edit control. If that is correct:

1. Verify that there is a defined key
1a. Should be a PRIMARY KEY definition
1b. Could be a UNIQUE constraint
1c. Might be a UNIQUE INDEX
2. Identify all columns in all of the potential defined key(s) from step 1.
3. Ensure that all of the columns from at least one of the defined keys are present in your edit control.

-PatP|||thanks but i didnt use access. i copy and paste a row in my table. then i wanted to delete that row but i cant delete. all of my other rows can be cleaned but that row cant be delete.|||Nope, it isn't possible to "copy and paste a row in my table" because there isn't any GUI representation for a table. What you are doing (very possibly without realizing it) is copying and pasting within some application running on your machine, not actually on the table itself.

Since you haven't given us (the readers) many clues, but you have ruled out Microsoft Access, I'll make another guess... This time I'll guess Captain Peacock, in the Drawing Room... Oh wait, wrong game! ;)

Let's try this guess: Are you possibly using SQL Enterprise Manager, and Editing a table grid control? If so, please let me know and we can start to solve your problem... If not, I might try to guess again!

Just in case you didn't get the idea, I'm frustrated. You're asking me to help you solve a problem, but you haven't given me anything concrete to work from. I assume that you are using SQL Server, and that you haven't used it very much so you're handicapped in explaining your problem, and it appears that English isn't your native language which would further complicate things for you... I'm trying to help, but I need you to help me more so that I can help you!

If you can read English comfortably, please see this forum's FAQ for Brett Kaiser's excellent suggestions for How to Ask a Question to Get Quick and Correct Answers (http://www.dbforums.com/showthread.php?t=1212452#post4527530).

-PatP|||yes! you are right. im sorry. now i am using sql server 2000 enterprise manager. i create a table (same nortwind "order details"). remember i create an olap cube such as nwind
here is my fields:

accountno (varchar50)
medicineno(nvarchar15)
saleprice(float8)
quantity(float8)

i click return all rows and enter my records

1 101 $4 3
1 102 $3 2
2 102 $5 3
3 207 $2 1
....................
56 101 $4 2

and then i copy this row (2 102 $3 2) and paste it

........................
56 101 $4 2
2 102 $3 2

then i wanted to delete that row (2 102 $3 2)
but it cant be deleted. warning: "key column info insufficient or wrong. updating affects more rows" (i translated english. maybe it can be wrong)|||Have dealt with this in the past dealing with others issues.

You need to write a delete statment to accomplish this in query analyzer.

delete from table where accountno = 2

try inserting a new row as follows|||The problem stems from the fact that you do not have a unique primary key defined on your table. Thus, when you try to delete one record SQL Server cannot tell which record it is.
Add a primary key to your table. A surrogate key will do fine. But I also agree that you should not edit data from the Enterprise Manager GUI. Use Query Analyzer.|||thanks i will try

Monday, March 12, 2012

I am scripting drop PRIMARY KEY script, but got DROP TABLE script

I am scripting the drop PRIMARY KEY script for all tables. But the script I got was DROP TABLE. Script options are as following:

so.DriUniqueKeys = false;

so.DriDefaults = false;

so.DriChecks = false;

so.Indexes = false;

so.DriForeignKeys = false;

so.PrimaryObject = false;

so.DriPrimaryKey = true;

so.IncludeIfNotExists = true;

so.ScriptDrops = true;

The create PRIMARY KEY script is right if I change so.ScriptDrops to false.

Am i doing something wrong or is it a bug? How to script out drop PK script?

hard to tell without the rest of your script, but what about that one here:

Server s = new Server(".");

s.ConnectionContext.SqlExecutionModes = SqlExecutionModes.CaptureSql;

foreach (Table t in s.Databases["Adventureworks"].Tables)

{

foreach (Index i in t.Indexes)

{

if (i.IndexKeyType == IndexKeyType.DriPrimaryKey)

{

i.Drop();

break;

}

}

}

s.Alter();

foreach (string st in s.ConnectionContext.CapturedSql.Text)

{

Console.WriteLine(st);

Console.ReadLine();

}

Jens K. Suessmeyer.

http://www.sqlserver2005.de
|||

Thanks Jens, It works great.

Based on my test, the DriPrimaryKey=true only works for create script for tables. DriPrimaryObject=false only works for create script for tables too. For drop script,smo always generates drop table script. That's why I got drop table script when i tried to generate drop PK script (DriPrimaryKey=true and

DriPrimaryObject=false ).

The BOL lacks details about the scripting options.

Wednesday, March 7, 2012

hyperthreading disabled?

Hi, can anyone tell me if it's possible to see the current hyperthreading value without going into the bios? registry key perhaps?

We have a very crooked system here and I do not have full access to the system. Thank you all for you all your help in the past! and the future!!

You could use 'Task Manager', and look at the [Performace] tab. (On the [View] menu, select [CPU History] and make sure the [One Graph per CPU] is checked.

If Hyperthreading is enabled, there will be 2 CPU Usage History graphs per physical CPU in the box.

|||what if there were two physical chips in there? wouldn't that still show 2 graphs?|||

i'm trying to determine how many actual chips there are.. is this doable without rebooting?

|||

With Hyperthreading enabled, two physical chips will display four CPU History graphs.

The [CPU History] graph displays for 'logical' chips. Hyperthreading makes two 'logical' chips from one physical chip.

|||

Which version of SQL Server are you using? If you are using SQL Server 2005 then you can query sys.dm_os_sys_info to find if you have a hyperthreaded or multi-code CPU. See the blog article below for the details:

http://blogs.msdn.com/sqltips/archive/2005/09/14/466387.aspx

Or download and install Process Explorer from the link below. You can then go to System information dialog, hover over the CPU usage graphs on top and they will show you if the processor is in the same core or not. See the utility for more details.

http://www.microsoft.com/technet/sysinternals/SystemInformation/ProcessExplorer.mspx

These are the easy methods. You can also type SYSTEMINFO in the command-line and use the processor description from their to figure it out. But this will require looking at Intel/AMD documentation for example to figure out the family of processors etc.

|||

Umachandar,

As I recall, the method descibed can't discern between Hyperthreading and Multi-core.

|||Yes, I mentioned it is for multi-core or hyperthreaded CPUs. Best is to install Process Explorer.