June 11, 2010 at 3:37 pm
I am just beginning to learn SQL Server. I am trying to create stored procedure. Before I can do that, I realised I needed to add more records to my DB. So I am trying to add new records into a table in my DB. Whne i use the INSERT INTO query, it says the command is executed successfully. But when I try to test it by using the SELECT query, I am not able to look at the newly inserted record into the table. Anyone knows whats going on??? Thanks!!!!!!!!!!!
June 11, 2010 at 3:52 pm
It is impossible to answer definitively without more information.
If I were to hazard a few guesses.
1. You may be reading and writing to tables in different schemas. Qualify your objects (i.e. insert into dbo.mytable... select * from dbo.mytable)
2. Your insert statement is not inserting anything (e.g. insert into dbo.mytable(a,b) select a, b from dbo.myOtherTable where 1=0 will not insert any rows likewise if you are inner joining to an empty table.) If you are using the INSERT...SELECT... syntax, verify that your select statement returns records.
3. You are making a mistake in your select statement. Make sure you are looking at the table without a where clause first to ensure you're not filtering everything out.
There are other possibilities, but these are the most likely. It would be really helpful if you posted your insert and select statement (and perhaps even the script to create your table)
SQL guy and Houston Magician
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply