Loading ...
Sorry, an error occurred while loading the content.

RE: [SQLQueriesNoCode] check for table

Expand Messages
  • alex.benitez@prgx.com
    That worked! thanks Regards, Alex Benitez Mark Gorelik Sent by: SQLQueriesNoCode@yahoogroups.com 04/22/2005 10:55 AM Please
    Message 1 of 9 , Apr 22, 2005
    • 0 Attachment

      That worked! thanks

      Regards,
      Alex Benitez




      "Mark Gorelik" <MGorelik@...>
      Sent by: SQLQueriesNoCode@yahoogroups.com

      04/22/2005 10:55 AM

      Please respond to
      SQLQueriesNoCode@yahoogroups.com

      To
      <SQLQueriesNoCode@yahoogroups.com>
      cc
      Subject
      RE: [SQLQueriesNoCode] check for table





      something like this .
      IF EXISTS (SELECT * FROM sysobjects WHERE name = 'mytable') DROP TABLE mytable
      -----Original Message-----
      From:
      SQLQueriesNoCode@yahoogroups.com [mailto:SQLQueriesNoCode@yahoogroups.com]On Behalf Of alex.benitez@...
      Sent:
      Friday, April 22, 2005 10:48 AM
      To:
      SQLQueriesNoCode@yahoogroups.com
      Cc:
      SQLQueriesNoCode@yahoogroups.com
      Subject:
      RE: [SQLQueriesNoCode] check for table


      It will give me an error that table doesn't exists... I made it into a DTS package and it will not finish if there is an error.


      Regards,
      Alex Benitez



      "John Warner" <john@...>
      Sent by: SQLQueriesNoCode@yahoogroups.com

      04/22/2005 09:55 AM

      Please respond to
      SQLQueriesNoCode@yahoogroups.com


      To
      <SQLQueriesNoCode@yahoogroups.com>
      cc
      Subject
      RE: [SQLQueriesNoCode] check for table







      DROP it everytime and don't concern yourself with checking if it exists.  Again as long as you intend to actually drop the table if it exists.

       

      John Warner

      -----Original Message-----
      From:
      SQLQueriesNoCode@yahoogroups.com [mailto:SQLQueriesNoCode@yahoogroups.com] On Behalf Of alex.benitez@...
      Sent:
      Friday, April 22, 2005 9:12 AM
      To:
      SQLQueriesNoCode@yahoogroups.com
      Subject:
      [SQLQueriesNoCode] check for table



      I have a query that creates a table.. e.g.

      Select *

      into mytable

      from table


      How can i check to see if mytable exists before running the above query so that i can drop it if it does exists?


      Regards,
      Alex Benitez
      732-845-1805



      Yahoo! Groups Links
      *** This communication is strictly private and contains confidential information intended solely for the addressee(s). Access to this communication by parties other than the intended recipient(s) is unauthorized. If you have received this communication in error and are not the intended recipient, any disclosure, copying, distribution or action taken is strictly prohibited and may be unlawful. ***

      *** Ce message est strictement prive et contient des renseignements confidentiels destines uniquement au(x) destinataire(s). L'acces a ce message par des parties autres que le(s) destinataire(s) prevu(s) n'est pas autorise. Si vous avez re├žu ce message par erreur et n'etes pas le destinataire prevu, toute divulgation, copie, distribution ou action prise est strictement interdite et peut etre consideree comme illegale. ***


      Yahoo! Groups Links
    • Arindam
      Hi Champs, can somone rectify the following problem. Very simple for u guys. Problem is with Like %% in sql qry. in Situation 1. i have written a simple
      Message 2 of 9 , Apr 24, 2005
      • 0 Attachment


        Hi Champs, can somone rectify the following problem.


        Very simple for u guys.
        Problem is with "Like '%%'" in sql qry.
        in "Situation 1." i have written a simple function which will return a tables
        where any of the following parameter match.
        so i have used "OR"

        Function is created , but it doesnot give proper output.

        When the sme was i have used "like and or in "Situation 2.", which gives proper output.

        Thanks
        Arindam


        Situation 1.
        ===========================
        Create Function fn_MyHotels
        (@hotelName varchar(50)=null,
        @city  varchar(50)=null,
        @category  varchar(50)=null)
        returns table
        as
        return (Select A.HOTEL_ID,A.userId,A.hotelName,A.category,A.country,A.state,A.city,A.street,A.hotelFacilities,
        IsNull(B.Picture_Path,'/images/Sample_Hotel_Stamp.gif') as Picture_Path,IsNull(B.Pic_Name,'Not Set')as Pic_Name
        from Hotel_Details A Left Outer Join Hotel_PicturePaths B
        on A.HOTEL_ID=B.HOTEL_ID
        where A.hotelName like '%'+@hotelName+'%' OR
        A.city like '%'+@city+'%'  OR
        A.category like '%'+@category+'%'
        )

        Situation 2.
        ===========================
        Select HOTEL_ID,userId,hotelName,category,country,state,city from Hotel_Details
        Where hotelName like '%ov%' or city like '%im%'



        Thanks & Regards

        Arindam
        Web Designer & Developer
         

        Yahoo! India Matrimony: Find your life partner online.

      • John Warner
        Could you give us a hint as to what return set you want from situation 1 as opposed to what you are getting? What is wrong in short? John Warner ... From:
        Message 3 of 9 , Apr 24, 2005
        • 0 Attachment
          Message
          Could you give us a hint as to what return set you want from situation 1 as opposed to what you are getting? What is wrong in short?
           
           

          John Warner

          -----Original Message-----
          From: SQLQueriesNoCode@yahoogroups.com [mailto:SQLQueriesNoCode@yahoogroups.com] On Behalf Of Arindam
          Sent: Sunday, April 24, 2005 4:42 AM
          To: SQLQueriesNoCode@yahoogroups.com
          Subject: [SQLQueriesNoCode] Problem is with "Like '%%'" in sql qry


          Hi Champs, can somone rectify the following problem.


          Very simple for u guys.
          Problem is with "Like '%%'" in sql qry.
          in "Situation 1." i have written a simple function which will return a tables
          where any of the following parameter match.
          so i have used "OR"

          Function is created , but it doesnot give proper output.

          When the sme was i have used "like and or in "Situation 2.", which gives proper output.

          Thanks
          Arindam


          Situation 1.
          ===========================
          Create Function fn_MyHotels
          (@hotelName varchar(50)=null,
          @city  varchar(50)=null,
          @category  varchar(50)=null)
          returns table
          as
          return (Select A.HOTEL_ID,A.userId,A.hotelName,A.category,A.country,A.state,A.city,A.street,A.hotelFacilities,
          IsNull(B.Picture_Path,'/images/Sample_Hotel_Stamp.gif') as Picture_Path,IsNull(B.Pic_Name,'Not Set')as Pic_Name
          from Hotel_Details A Left Outer Join Hotel_PicturePaths B
          on A.HOTEL_ID=B.HOTEL_ID
          where A.hotelName like '%'+@hotelName+'%' OR
          A.city like '%'+@city+'%'  OR
          A.category like '%'+@category+'%'
          )

          Situation 2.
          ===========================
          Select HOTEL_ID,userId,hotelName,category,country,state,city from Hotel_Details
          Where hotelName like '%ov%' or city like '%im%'



          Thanks & Regards

          Arindam
          Web Designer & Developer
           

          Yahoo! India Matrimony: Find your life partner online.

        • Arindam
          John, What i m getting from situation 2, not getting from situation 1. means i am not getting those record which match %word% from my function, mainly when i
          Message 4 of 9 , Apr 25, 2005
          • 0 Attachment
            John,
            What i m getting from situation 2, not getting from situation 1.
            means i am not getting those record which match '%word%' from my function, mainly when i am calling that from my asp pages .


            John Warner <john@...> wrote:
            Could you give us a hint as to what return set you want from situation 1 as opposed to what you are getting? What is wrong in short?
             
             

            John Warner

            -----Original Message-----
            From: SQLQueriesNoCode@yahoogroups.com [mailto:SQLQueriesNoCode@yahoogroups.com] On Behalf Of Arindam
            Sent: Sunday, April 24, 2005 4:42 AM
            To: SQLQueriesNoCode@yahoogroups.com
            Subject: [SQLQueriesNoCode] Problem is with "Like '%%'" in sql qry


            Hi Champs, can somone rectify the following problem.


            Very simple for u guys.
            Problem is with "Like '%%'" in sql qry.
            in "Situation 1." i have written a simple function which will return a tables
            where any of the following parameter match.
            so i have used "OR"

            Function is created , but it doesnot give proper output.

            When the sme was i have used "like and or in "Situation 2.", which gives proper output.

            Thanks
            Arindam


            Situation 1.
            ===========================
            Create Function fn_MyHotels
            (@hotelName varchar(50)=null,
            @city  varchar(50)=null,
            @category  varchar(50)=null)
            returns table
            as
            return (Select A.HOTEL_ID,A.userId,A.hotelName,A.category,A.country,A.state,A.city,A.street,A.hotelFacilities,
            IsNull(B.Picture_Path,'/images/Sample_Hotel_Stamp.gif') as Picture_Path,IsNull(B.Pic_Name,'Not Set')as Pic_Name
            from Hotel_Details A Left Outer Join Hotel_PicturePaths B
            on A.HOTEL_ID=B.HOTEL_ID
            where A.hotelName like '%'+@hotelName+'%' OR
            A.city like '%'+@city+'%'  OR
            A.category like '%'+@category+'%'
            )

            Situation 2.
            ===========================
            Select HOTEL_ID,userId,hotelName,category,country,state,city from Hotel_Details
            Where hotelName like '%ov%' or city like '%im%'



            Thanks & Regards

            Arindam
            Web Designer & Developer
             

            Yahoo! India Matrimony: Find your life partner online.



            Thanks & Regards

            Arindam
            Web Designer & Developer
             

            Yahoo! India Matrimony: Find your life partner online.

          • John Warner
            Ok, there are a lot of things to check here. First, what are you passing to the proc variables (@hotelname, @city, etc). What I mean is what exactly comes into
            Message 5 of 9 , Apr 25, 2005
            • 0 Attachment
              Message
              Ok, there are a lot of things to check here. First, what are you passing to the proc variables (@hotelname, @city, etc). What I mean is what exactly comes into the proc from the ASP (don't give me more variable names, what exactly do the strings look like? Are you sure they are getting into the ASP variables from the text fields in your page?
               
              Situation two does not have a self join, situation 1 does, why?
               
               

              John Warner

              -----Original Message-----
              From: SQLQueriesNoCode@yahoogroups.com [mailto:SQLQueriesNoCode@yahoogroups.com] On Behalf Of Arindam
              Sent: Monday, April 25, 2005 1:36 PM
              To: SQLQueriesNoCode@yahoogroups.com
              Subject: RE: [SQLQueriesNoCode] Problem is with "Like '%%'" in sql qry

              John,
              What i m getting from situation 2, not getting from situation 1.
              means i am not getting those record which match '%word%' from my function, mainly when i am calling that from my asp pages .


              John Warner <john@...> wrote:
              Could you give us a hint as to what return set you want from situation 1 as opposed to what you are getting? What is wrong in short?
               
               

              John Warner

              -----Original Message-----
              From: SQLQueriesNoCode@yahoogroups.com [mailto:SQLQueriesNoCode@yahoogroups.com] On Behalf Of Arindam
              Sent: Sunday, April 24, 2005 4:42 AM
              To: SQLQueriesNoCode@yahoogroups.com
              Subject: [SQLQueriesNoCode] Problem is with "Like '%%'" in sql qry


              Hi Champs, can somone rectify the following problem.


              Very simple for u guys.
              Problem is with "Like '%%'" in sql qry.
              in "Situation 1." i have written a simple function which will return a tables
              where any of the following parameter match.
              so i have used "OR"

              Function is created , but it doesnot give proper output.

              When the sme was i have used "like and or in "Situation 2.", which gives proper output.

              Thanks
              Arindam


              Situation 1.
              ===========================
              Create Function fn_MyHotels
              (@hotelName varchar(50)=null,
              @city  varchar(50)=null,
              @category  varchar(50)=null)
              returns table
              as
              return (Select A.HOTEL_ID,A.userId,A.hotelName,A.category,A.country,A.state,A.city,A.street,A.hotelFacilities,
              IsNull(B.Picture_Path,'/images/Sample_Hotel_Stamp.gif') as Picture_Path,IsNull(B.Pic_Name,'Not Set')as Pic_Name
              from Hotel_Details A Left Outer Join Hotel_PicturePaths B
              on A.HOTEL_ID=B.HOTEL_ID
              where A.hotelName like '%'+@hotelName+'%' OR
              A.city like '%'+@city+'%'  OR
              A.category like '%'+@category+'%'
              )

              Situation 2.
              ===========================
              Select HOTEL_ID,userId,hotelName,category,country,state,city from Hotel_Details
              Where hotelName like '%ov%' or city like '%im%'



              Thanks & Regards

              Arindam
              Web Designer & Developer
               

              Yahoo! India Matrimony: Find your life partner online.



              Thanks & Regards

              Arindam
              Web Designer & Developer
               

              Yahoo! India Matrimony: Find your life partner online.

            Your message has been successfully submitted and would be delivered to recipients shortly.