<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://www.dotnetzone.gr:443/cs/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>SQL Server (και άλλες databases)</title><link>https://www.dotnetzone.gr:443/cs/forums/28/ShowForum.aspx</link><description>Θέματα που αφορούν τον SQL Server (7.0, 2000, 2005) αλλά και Oracle, Access, DB2, MySQL, κλπ.</description><dc:language>el</dc:language><generator>CommunityServer 2.1 SP3 (Build: 20423.1)</generator><item><title>Απ: Αναζήτηση</title><link>https://www.dotnetzone.gr:443/cs/forums/thread/18803.aspx</link><pubDate>Thu, 19 Oct 2006 18:17:58 GMT</pubDate><guid isPermaLink="false">2622095e-976c-431a-859e-16783ec7ecd7:18803</guid><dc:creator>KelMan</dc:creator><slash:comments>0</slash:comments><comments>https://www.dotnetzone.gr:443/cs/forums/thread/18803.aspx</comments><wfw:commentRss>https://www.dotnetzone.gr:443/cs/forums/commentrss.aspx?SectionID=28&amp;PostID=18803</wfw:commentRss><description>&lt;P&gt;&amp;nbsp;Χε χε χε... Όταν&amp;nbsp;διάβασα το query, λέω "χμμμ... και γιατί να μην βάλουμε το WHERE μέσα σε κάθε sub-select", δηλαδή:&lt;/P&gt;
&lt;P&gt;&lt;span style="color: Black;background-color: Transparent;font-family: Courier New;font-size: 11px;font-weight: normal;"&gt;&lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 11px;font-weight: normal;"&gt;SELECT&lt;/span&gt; * &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 11px;font-weight: normal;"&gt;FROM&lt;/span&gt;&lt;br /&gt;(&lt;br /&gt;&lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 11px;font-weight: normal;"&gt;SELECT&lt;/span&gt; ID, &lt;span style="color: Red;background-color: Transparent;font-family: Courier New;font-size: 11px;font-weight: normal;"&gt;'Text_GR'&lt;/span&gt; FieldName, Text_GR FieldValue &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 11px;font-weight: normal;"&gt;FROM&lt;/span&gt; tbl &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 11px;font-weight: normal;"&gt;WHERE&lt;/span&gt; Text_GR &lt;span style="color: Silver;background-color: Transparent;font-family: Courier New;font-size: 11px;font-weight: normal;"&gt;LIKE&lt;/span&gt; &lt;span style="color: Red;background-color: Transparent;font-family: Courier New;font-size: 11px;font-weight: normal;"&gt;'%T%'&lt;/span&gt;&lt;br /&gt;    &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 11px;font-weight: normal;"&gt;UNION&lt;/span&gt;&lt;br /&gt;&lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 11px;font-weight: normal;"&gt;SELECT&lt;/span&gt; ID, &lt;span style="color: Red;background-color: Transparent;font-family: Courier New;font-size: 11px;font-weight: normal;"&gt;'Text_EN'&lt;/span&gt; FieldName, Text_EN FieldValue &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 11px;font-weight: normal;"&gt;FROM&lt;/span&gt; tbl &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 11px;font-weight: normal;"&gt;WHERE&lt;/span&gt; Text_EN &lt;span style="color: Silver;background-color: Transparent;font-family: Courier New;font-size: 11px;font-weight: normal;"&gt;LIKE&lt;/span&gt; &lt;span style="color: Red;background-color: Transparent;font-family: Courier New;font-size: 11px;font-weight: normal;"&gt;'%T%'&lt;/span&gt;&lt;br /&gt;    &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 11px;font-weight: normal;"&gt;UNION&lt;/span&gt;&lt;br /&gt;&lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 11px;font-weight: normal;"&gt;SELECT&lt;/span&gt; ID, &lt;span style="color: Red;background-color: Transparent;font-family: Courier New;font-size: 11px;font-weight: normal;"&gt;'Text_FR'&lt;/span&gt; FieldName, Text_FR FieldValue &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 11px;font-weight: normal;"&gt;FROM&lt;/span&gt; tbl &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 11px;font-weight: normal;"&gt;WHERE&lt;/span&gt; Text_FR &lt;span style="color: Silver;background-color: Transparent;font-family: Courier New;font-size: 11px;font-weight: normal;"&gt;LIKE&lt;/span&gt; &lt;span style="color: Red;background-color: Transparent;font-family: Courier New;font-size: 11px;font-weight: normal;"&gt;'%T%'&lt;/span&gt;&lt;br /&gt;) X&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Δεν παίζει ρόλο όμως, ο query optimizer τιμά το όνομά του... Παράγεται το ίδιο execution plan και στις δύο περιπτώσεις &lt;img src="/cs/emoticons/emotion-1.gif" alt="Smile" /&gt;&lt;/P&gt;</description></item><item><title>Απ: Αναζήτηση</title><link>https://www.dotnetzone.gr:443/cs/forums/thread/18798.aspx</link><pubDate>Thu, 19 Oct 2006 17:01:07 GMT</pubDate><guid isPermaLink="false">2622095e-976c-431a-859e-16783ec7ecd7:18798</guid><dc:creator>Νατάσα Μανουσοπούλου</dc:creator><slash:comments>0</slash:comments><comments>https://www.dotnetzone.gr:443/cs/forums/thread/18798.aspx</comments><wfw:commentRss>https://www.dotnetzone.gr:443/cs/forums/commentrss.aspx?SectionID=28&amp;PostID=18798</wfw:commentRss><description>Υπάρχει μια λύση και σε αυτό, η οποία δεν είναι και η αποδοτικότερη του κόσμου, αλλά δουλεύει παρόλα αυτά:&lt;br&gt;&lt;span style="color: Black;background-color: Transparent;font-family: Courier New;font-size: 11px;font-weight: normal;"&gt;&lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 11px;font-weight: normal;"&gt;SELECT&lt;/span&gt; * &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 11px;font-weight: normal;"&gt;FROM&lt;/span&gt;&lt;br /&gt;(&lt;br /&gt;&lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 11px;font-weight: normal;"&gt;SELECT&lt;/span&gt; ID, &lt;span style="color: Red;background-color: Transparent;font-family: Courier New;font-size: 11px;font-weight: normal;"&gt;'Text_GR'&lt;/span&gt; FieldName, Text_GR FieldValue &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 11px;font-weight: normal;"&gt;FROM&lt;/span&gt; tbl&lt;br /&gt;    &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 11px;font-weight: normal;"&gt;UNION&lt;/span&gt;&lt;br /&gt;&lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 11px;font-weight: normal;"&gt;SELECT&lt;/span&gt; ID, &lt;span style="color: Red;background-color: Transparent;font-family: Courier New;font-size: 11px;font-weight: normal;"&gt;'Text_EN'&lt;/span&gt; FieldName, Text_EN FieldValue &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 11px;font-weight: normal;"&gt;FROM&lt;/span&gt; tbl&lt;br /&gt;    &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 11px;font-weight: normal;"&gt;UNION&lt;/span&gt;&lt;br /&gt;&lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 11px;font-weight: normal;"&gt;SELECT&lt;/span&gt; ID, &lt;span style="color: Red;background-color: Transparent;font-family: Courier New;font-size: 11px;font-weight: normal;"&gt;'Text_FR'&lt;/span&gt; FieldName, Text_FR FieldValue &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 11px;font-weight: normal;"&gt;FROM&lt;/span&gt; tbl&lt;br /&gt;) X&lt;br /&gt;&lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 11px;font-weight: normal;"&gt;WHERE&lt;/span&gt; X.FieldValue &lt;span style="color: Silver;background-color: Transparent;font-family: Courier New;font-size: 11px;font-weight: normal;"&gt;LIKE&lt;/span&gt; &lt;span style="color: Red;background-color: Transparent;font-family: Courier New;font-size: 11px;font-weight: normal;"&gt;'%T%'&lt;/span&gt;&lt;/span&gt;&lt;br&gt;</description></item><item><title>Απ: Αναζήτηση</title><link>https://www.dotnetzone.gr:443/cs/forums/thread/18794.aspx</link><pubDate>Thu, 19 Oct 2006 15:17:20 GMT</pubDate><guid isPermaLink="false">2622095e-976c-431a-859e-16783ec7ecd7:18794</guid><dc:creator>KelMan</dc:creator><slash:comments>0</slash:comments><comments>https://www.dotnetzone.gr:443/cs/forums/thread/18794.aspx</comments><wfw:commentRss>https://www.dotnetzone.gr:443/cs/forums/commentrss.aspx?SectionID=28&amp;PostID=18794</wfw:commentRss><description>Μόνο προσοχή γιατί το CASE σταματάει στο πρώτο WHEN που θα γίνει true, οπότε αν το text υπάρχει σε πολλαπλά columns τότε θα πάρεις μόνο το πρώτο. Για κάτι που να έχει καλύτερη λογική, θα πρέπει να πας σε stored procedure.</description></item><item><title>Απ: Αναζήτηση</title><link>https://www.dotnetzone.gr:443/cs/forums/thread/18792.aspx</link><pubDate>Thu, 19 Oct 2006 09:39:49 GMT</pubDate><guid isPermaLink="false">2622095e-976c-431a-859e-16783ec7ecd7:18792</guid><dc:creator>vangelisan</dc:creator><slash:comments>0</slash:comments><comments>https://www.dotnetzone.gr:443/cs/forums/thread/18792.aspx</comments><wfw:commentRss>https://www.dotnetzone.gr:443/cs/forums/commentrss.aspx?SectionID=28&amp;PostID=18792</wfw:commentRss><description>Πανέξυπνο KelMan&lt;br /&gt;
&lt;br /&gt;
Ευχαριστώ</description></item><item><title>Απ: Αναζήτηση</title><link>https://www.dotnetzone.gr:443/cs/forums/thread/18791.aspx</link><pubDate>Thu, 19 Oct 2006 09:24:11 GMT</pubDate><guid isPermaLink="false">2622095e-976c-431a-859e-16783ec7ecd7:18791</guid><dc:creator>KelMan</dc:creator><slash:comments>0</slash:comments><comments>https://www.dotnetzone.gr:443/cs/forums/thread/18791.aspx</comments><wfw:commentRss>https://www.dotnetzone.gr:443/cs/forums/commentrss.aspx?SectionID=28&amp;PostID=18791</wfw:commentRss><description>&lt;P&gt;To παρακάτω προσθέτει στο output ένα extra πεδίο (FoundField) που έχει τιμή το πεδίο που περιέχει την τιμή αναζήτησης. &lt;/P&gt;
&lt;P&gt;&lt;span style="color: Black;background-color: Transparent;font-family: Courier New;font-size: 11px;font-weight: normal;"&gt; &lt;br /&gt;&lt;br /&gt;&lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 11px;font-weight: normal;"&gt;SELECT&lt;/span&gt;  *,&lt;br /&gt;        &lt;span style="color: Fuchsia;background-color: Transparent;font-family: Courier New;font-size: 11px;font-weight: normal;"&gt;CASE&lt;/span&gt; &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 11px;font-weight: normal;"&gt;WHEN&lt;/span&gt; text_gr &lt;span style="color: Silver;background-color: Transparent;font-family: Courier New;font-size: 11px;font-weight: normal;"&gt;LIKE&lt;/span&gt; &lt;span style="color: Red;background-color: Transparent;font-family: Courier New;font-size: 11px;font-weight: normal;"&gt;'%word%'&lt;/span&gt; &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 11px;font-weight: normal;"&gt;THEN&lt;/span&gt; &lt;span style="color: Red;background-color: Transparent;font-family: Courier New;font-size: 11px;font-weight: normal;"&gt;'text_gr'&lt;/span&gt;&lt;br /&gt;             &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 11px;font-weight: normal;"&gt;WHEN&lt;/span&gt; text_en &lt;span style="color: Silver;background-color: Transparent;font-family: Courier New;font-size: 11px;font-weight: normal;"&gt;LIKE&lt;/span&gt; &lt;span style="color: Red;background-color: Transparent;font-family: Courier New;font-size: 11px;font-weight: normal;"&gt;'%word%'&lt;/span&gt; &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 11px;font-weight: normal;"&gt;THEN&lt;/span&gt; &lt;span style="color: Red;background-color: Transparent;font-family: Courier New;font-size: 11px;font-weight: normal;"&gt;'text_en'&lt;/span&gt;&lt;br /&gt;             &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 11px;font-weight: normal;"&gt;WHEN&lt;/span&gt; text_fr &lt;span style="color: Silver;background-color: Transparent;font-family: Courier New;font-size: 11px;font-weight: normal;"&gt;LIKE&lt;/span&gt; &lt;span style="color: Red;background-color: Transparent;font-family: Courier New;font-size: 11px;font-weight: normal;"&gt;'%word%'&lt;/span&gt; &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 11px;font-weight: normal;"&gt;THEN&lt;/span&gt; &lt;span style="color: Red;background-color: Transparent;font-family: Courier New;font-size: 11px;font-weight: normal;"&gt;'text_fr'&lt;/span&gt;&lt;br /&gt;&lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 11px;font-weight: normal;"&gt;END&lt;/span&gt; &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 11px;font-weight: normal;"&gt;AS&lt;/span&gt; FoundField&lt;br /&gt;&lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 11px;font-weight: normal;"&gt;FROM&lt;/span&gt;    tbl&lt;br /&gt;&lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 11px;font-weight: normal;"&gt;WHERE&lt;/span&gt;   text_gr &lt;span style="color: Silver;background-color: Transparent;font-family: Courier New;font-size: 11px;font-weight: normal;"&gt;LIKE&lt;/span&gt; &lt;span style="color: Red;background-color: Transparent;font-family: Courier New;font-size: 11px;font-weight: normal;"&gt;'%word%'&lt;/span&gt;&lt;br /&gt;        &lt;span style="color: Silver;background-color: Transparent;font-family: Courier New;font-size: 11px;font-weight: normal;"&gt;OR&lt;/span&gt; text_en &lt;span style="color: Silver;background-color: Transparent;font-family: Courier New;font-size: 11px;font-weight: normal;"&gt;LIKE&lt;/span&gt; &lt;span style="color: Red;background-color: Transparent;font-family: Courier New;font-size: 11px;font-weight: normal;"&gt;'%word%'&lt;/span&gt;&lt;br /&gt;        &lt;span style="color: Silver;background-color: Transparent;font-family: Courier New;font-size: 11px;font-weight: normal;"&gt;OR&lt;/span&gt; text_fr &lt;span style="color: Silver;background-color: Transparent;font-family: Courier New;font-size: 11px;font-weight: normal;"&gt;LIKE&lt;/span&gt; &lt;span style="color: Red;background-color: Transparent;font-family: Courier New;font-size: 11px;font-weight: normal;"&gt;'%word%'&lt;/span&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description></item><item><title>Αναζήτηση</title><link>https://www.dotnetzone.gr:443/cs/forums/thread/18790.aspx</link><pubDate>Thu, 19 Oct 2006 09:02:07 GMT</pubDate><guid isPermaLink="false">2622095e-976c-431a-859e-16783ec7ecd7:18790</guid><dc:creator>vangelisan</dc:creator><slash:comments>0</slash:comments><comments>https://www.dotnetzone.gr:443/cs/forums/thread/18790.aspx</comments><wfw:commentRss>https://www.dotnetzone.gr:443/cs/forums/commentrss.aspx?SectionID=28&amp;PostID=18790</wfw:commentRss><description>&lt;P&gt;Εχω έναν πίνακα ας πούμε tbl, ο οποίος περιέχει&amp;nbsp;3 πεδία nvarchar ας πουμε : text_gr, text_en και text_fr &lt;/P&gt;
&lt;P&gt;Στο παραπάνω πίνακα κάνω αναζήτηση για να βρώ εαν ή λέξη word υπάρχει σ' αυτά τα πεδία, με to εξής ερώτημα :&lt;/P&gt;
&lt;P&gt;SELECT *&lt;BR&gt;FROM tbl&lt;BR&gt;WHERE text_gr LIKE '%word%'&amp;nbsp;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; OR&amp;nbsp;text_en LIKE '%word%'&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;OR&amp;nbsp;text_fr LIKE '%word%' ;&lt;/P&gt;
&lt;P&gt;Υπάρχει τρόπος, σε περίπτωση που η λέξη βρεθεί μέσα σε κάποιο από αυτά τα πεδία, o server να μου επιστρέψει το όνομα του πεδίου στο οποίο βρέθηκε ?&lt;BR&gt;&lt;/P&gt;
&lt;P&gt;Βαγγέλης&lt;/P&gt;</description></item></channel></rss>