• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 268
  • Last Modified:

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
0
Bob Bender
Asked:
Bob Bender
  • 2
1 Solution
 
Aaron TomoskyTechnology ConsultantCommented:
1- I agree

2)  declare@ident;
Select ident doesn't make sense

3- also @count
0
 
Bob BenderAuthor Commented:

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
0
 
Aaron TomoskyTechnology ConsultantCommented:
I dont know

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

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now