SQL Command Help

Posted on 2011-10-08
Last Modified: 2012-05-12

Friend helping me learn...

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

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

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'

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

4)  Merge tblOne
     Using tblTwo
     On (tblOne.brand = tblTwo.brand)
     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
Question by:Bob Bender
    LVL 38

    Accepted Solution

    1- I agree

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

    3- also @count
    LVL 5

    Author Comment

    by:Bob Bender

    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)?

    LVL 38

    Expert Comment

    by:Aaron Tomosky
    I dont know

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

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    6 Surprising Benefits of Threat Intelligence

    All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

    Naughty Me. While I was changing the database name from DB1 to DB_PROD1 (yep it's not real database name ^v^), I changed the database name and notified my application fellows that I did it. They turn on the application, and everything is working. A …
    In this article we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.
    Need more eyes on your posted question? Go ahead and follow the quick steps in this video to learn how to Request Attention to your question. *Log into your Experts Exchange account *Find the question you want to Request Attention for *Go to the e…
    This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor ( If you're looking for how to monitor bandwidth using netflow or packet s…

    737 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    21 Experts available now in Live!

    Get 1:1 Help Now