Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
Naeemeh
Starting Member
3 Posts |
Posted - 2010-08-03 : 14:59:44
|
| Hi,Can you tell me what is wrong with this query:"if not exists TestDieFile values(7)"TestDieFile is a table that has a column that accepts integer.I want to insert 7 into the table if it doesn't already exists in the table. But I keep getting this error:"Msg 102, Level 15, State 1, Line 1Incorrect syntax near 'TestDieFile'." I tried putting the the "if not exists" phrase at the beginning of the query too, but I get the same error.Please tell me what I'm doing wrong? How should I user "if not exists"?Thanks alot,Naeemeh |
|
|
Naeemeh
Starting Member
3 Posts |
Posted - 2010-08-03 : 15:09:33
|
| Corrections:the query is: "insert if not exists TestDieFile values(7) "and the error I get is :"Msg 156, Level 15, State 1, Line 1Incorrect syntax near the keyword 'if'.Msg 102, Level 15, State 1, Line 1Incorrect syntax near 'TestDieFile'." |
 |
|
|
X002548
Not Just a Number
15586 Posts |
|
|
Naeemeh
Starting Member
3 Posts |
Posted - 2010-08-03 : 15:22:14
|
| Thank you soooooo much :D |
 |
|
|
X002548
Not Just a Number
15586 Posts |
Posted - 2010-08-03 : 15:29:34
|
quote: Originally posted by Naeemeh Thank you soooooo much :D
Our Pleasure..DECLARE @QuestionAsked datetime; SET @QuestionAsked = '08/03/2010 14:59:44' DECLARE @QuestionAnswered datetime; SET @QuestionAnswered = '08/03/2010 15:10:36'SELECT DATEDIFF(mi,@QuestionAsked, @QuestionAnswered) AS [TimeToAnswer(minutes)] Brett8-)Hint: Want your questions answered fast? Follow the direction in this linkhttp://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspxAdd yourself!http://www.frappr.com/sqlteam |
 |
|
|
|
|
|
|
|