siz
siz

Reputation: 21

SQL command is doubling up

In a project I made a table, but when I went to do: SELECT * FROM TableName I have been getting 101, 102, 103, 104, 105, 101, 102, 103, 104, 105. I only want it to do 101 - 105.

Create TABLE Cust (Customer_Number CHAR(3), address VARCHAR(20), balance SMALLMONEY

INSERT INTO Cust (Customer_number, balance, address)
    VALUES (101, 200, null), (102, 700, null), (103, 1000, null), (104, 1500, null), (105, 2000, null)

SELECT *
FROM Cust

That is what I have and as I said I keep getting 10 slots instead of 5. Not sure what I'm doing wrong, every time I have done the SELECT * FROM () command I have always got it to double or triple up? Any help will help also thanks in advanced.

Upvotes: 0

Views: 71

Answers (3)

Vipin Maurya
Vipin Maurya

Reputation: 58

Some times when we are in hurry and end up doing some thing wrong unknowingly. So please use

Truncate Table Table_name

to truncate the table and then re-insert the rows. Also keep in mind that char and varchar data needs to be within single quotes.

Upvotes: 0

Nagaraj S
Nagaraj S

Reputation: 13484

Its working fine.see here

SQl fiddle

Upvotes: 0

Mudassir Hasan
Mudassir Hasan

Reputation: 28771

You have done insertion on table multiple times . First empty all the data and then do the INSERT

TRUNCATE TABLE Cust 

Upvotes: 0

Related Questions