sql

How do you create a cumulative, "derived" column of ancestry using SQL Server 2008 hierarchyid

Imagine your typical manager / employee hierarchy, where you have an employee with a boss, who in turn has a boss, who in turn has a boss. How would you write a query that would have a column with, say, all the boss's names as a varchar. Given this data (leaving out the hierarchyid column but the id column here essentially describes th...

ms-access: single and double quotes in conditional formatting

does it matter which quotes i use when i do conditional formatting? for example some_field='this' or some_field="this" does it make any difference? ...

Visio 2003 ERM to SQL Server script

Hello, my question is simple: Is there anyway to generate the database sql creaton script from a Visio 2003 model? I prefer Visio, however can be other program (freeware) that allows me to somehow agilize the process between the model and the sql code. Thanks in advance! ...

What does +0 mean after an ORDER BY in Oracle

I am trying to understand what the +0 at the end of this Oracle 9i query means: SELECT /*+ INDEX (a CODE_ZIP_CODE_IX) */ a.city, a.state, LPAD(a.code,5,0) ZipCode, b.County_Name CoName, c.Description RegDesc, d.Description RegTypeDesc FROM TBL_CODE_ZIP a, TBL_CODE_COUN...

using IF statement instead of conditional formatting

since it seems that my conditional formatting statement is way too big: ([Panels] like '*IT_AMPH,*' or [Panels] like '*AMPH_SN,*' or [Panels] like '*AMPH_S,*') and ([Panels] like '*IT_BARB,*' or [Panels] like '*BARB_SN,*' or [Panels] like '*BARB_S,*') and ([Panels] like '*IT_BENZ,*' or [Panels] like '*BENZ_SN,*' or [Panels] like '*BENZ_...

vba: evaluating whether sql statement is true or false

how do i evaluate in VBA access whether the following statement is true: ([Panels] like '*IT_AMPH,*' or [Panels] like '*AMPH_SN,*' or [Panels] like '*AMPH_S,*') and ([Panels] like '*IT_BARB,*' or [Panels] like '*BARB_SN,*' or [Panels] like '*BARB_S,*') this is going to be running in Report_Load and i need to know whether the statement...

text-box conditional formatting dependent on other text-boxes

i have a bunch of textboxes on a report whose conditional formatting references the record i have another textbox on the report that references the TEXT in the textboxes mentioned above (which is dependent on the record set) the question is, will i have an accurate evaluation of a conditional formatting on a textbox that is referencing...

Where clause on a column that's a result of a UDF

I have a user defined function (e.g. myUDF(a,b)) that returns an integer. I am trying to ensure this function will be called only once and its results can be used as a condition in the WHERE clause: SELECT col1, col2, col3, myUDF(col1,col2) AS X From myTable WHERE x>0 SQL Server tries to detect x as column, but it's really an...

What does the return value of an Access/VBA expression mean?

I have a huge expression for a textbox in the CONTROL SOURCE. Sometimes it returns 0 and sometimes -1, what do these values mean? ...

How Would I Write This In LINQ2SQL?

I am slowly porting over an app from MySQL to use Linq2Sql - but one query has stumped me a bit. SELECT * FROM Pages WHERE DomainID = @reportid AND (PageContent REGEXP 'display\:[ \t]*none') > 0 ORDER BY URL ASC Any ideas on how I would write something like this with Linq2SQL? Its the REGEXP bit thats got me stumped? ...

ms-access: check if font color is white

in conditional formatting what would be the expression i would use to check whether a DIFFERENT textbox's font color is set to white? ...

SQL query at least one of something

Hello, I have a bunch of Users, each of whom has many Posts. Schema: Users: id Posts: user_id, rating How do I find all Users who have at least one post with a rating above, say, 10? I'm not sure if I should use a subQuery for this, or if there's an easier way. Thanks! ...

SQL: Is it efficient to use tinyint instead of Integer if my max value is 255 ?

Lets assume I want to save the count of datagrid rows which can be max. 24 because each row is 1 hour. To save the row index in the database a tinyint field would be totally enough. But back in my mind I remember slightly that databases are optimized for integers?! So is it worth to use tinyint? ...

Can I convert between timezones in SQL Server?

Right now I'm storing a number of records in SQL Server with a DATETIME column that stores the current timestamp using GETUTCDATE(). This ensures that we're always storing the exact date without having to worry about questions like "well is this 2:00 my time or 2:00 your time?" Using UTC ensures that we know exactly when it happened rega...

Group By and Aggregate function

I want to write an efficient query which returns a list of fruits by type, the lowest price for the type of fruit and the name of the fruit. Right now, I have a query which return me the fruit type and the lowest price for that type (see below). But I am unable to get the name of the cheapest fruit. Any idea how I can achieve that? Than...

Oracle PIVOT, twice?

I have been trying to move away from using DECODE to pivot rows in Oracle 11g, where there is a handy PIVOT function. But I may have found a limitation: I'm trying to return 2 columns for each value in the base table. Something like: SELECT somethingId, splitId1, splitName1, splitId2, splitName2 FROM (SELECT somethingId, splitId ...

SQL Sort/Cast last five chars question

I have a sticky SQL issue and I'm not the best with SQL... I have a table that has a varchar(40) column that has data in the following two formats: nn-nnn1nnn00000 nn-nnn-nnn-0000 The second data type is outdated; however because they are outdated they need to be viewed first in order. It was recommended to me to substring the last 5...

How to count records from multiple columns using sql and asp.net?

I have a table with 5 columns: ID, Session1, Session2, Session3, Session4. What I want to do is to display the number of same items from each column. Same item can't appear in more than one column. ID Session1 Session2 Session3 Session4 -- -------- -------- -------- -------- 1 Music Web Tech Fu...

Incorrect syntax near insert

Possible Duplicate: Incorrect syntax near insert For some reason I can't get the tables populated. It worked before but I don't know why it won't run now. CREATE DATABASE Mort; Go USE Mort; ----------------------------------- /* **This script creates the ** Employee table with the foreign key */ -------------------------...

Incorrect syntax near insert

I am a student this is homework... The tables are there but data isn't being inserted. Thanks for any advice Msg 156, Level 15, State 1, Line 181 Incorrect syntax near the keyword 'INSERT'. USE Mort; Go INSERT INTO Employee (Last_name, First_name, Address, City, State, Telephone_area_code, Telephone_number, Job_title, Hire_date,...