Link to home
Start Free TrialLog in
Avatar of Bob Bender
Bob BenderFlag for United States of America

asked on

SQL Command Help


Friend helping me learn...

Asked... Am I right in my thoughts...

1)  If Exists(Select * tblOne) Begin
     Update tblOne set field1 = 'true'
     End

Problem is  Missing FROM on Select?

2)  Insert into tblOne value (true, not burned)
     Select @@ident
     Update tblTwo set mgr = yes, Qualified = yes

Problem is yes not defined ?  NOt really sure about intent, maybe a true?

3)  Declare @count int
     Select @count = Count(totalNum) from tblOne where cooked='Rare'
     If count = Begin
     Update tblOne set MgrFlag = 'true'
     End

Problem is If statement needs a condition  like   If count = 1 Begin

4)  Merge tblOne
     Using tblTwo
     On (tblOne.brand = tblTwo.brand)
     WHEN MATCHED
     Then Insert into tblOne values('true' , 'not burned')

Syntax correct but will insert put data in 1st 2 fields of the table?

Any help appreciated
ASKER CERTIFIED SOLUTION
Avatar of Aaron Tomosky
Aaron Tomosky
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Bob Bender

ASKER


Okay....  coupla small followups...

a)  What does the @@ mean  in declaring?

b)  will data in Insert put data in 1st 2 fields of the table, or do I have to define names of fields (or is it optional)?

Thanx
I dont know

If you don't put field names it uses the first two fields.