sql

SQL - returning a list of id for every row in the database

Hi All, I have the following query DECLARE @tagIDs VARCHAR(1000) DECLARE @TagValues VARCHAR(8000) SELECT @tagIDs = ISNULL(@tagIDs + ',', '') + CAST(CTTagLookup.tagID AS VARCHAR(1000)), @TagValues = ISNULL(@TagValues + ',', '') + CAST(CTTag.tag AS VARCHAR(8000)) FROM CTTagLookup INNER JOIN CTTa...

php query function / class

It must be Monday, the heat or me being stupid (prob the latter), but for the life of me I cannot get a simple php function to work. I have a simple query $sql = mysql_query("SELECT * FROM table WHERE field_name = '$input'"); Which I want to run through a function: say: function functionname($input){ global $field1; global...

Can I have a mutex table in my database (Oracle) with just plain SQL?

I would like to have a table in my Oracle database whose rows act as locks. The table would have one column, a varchar, and my clients (Java processes over JDBC) would run statements to acquire and release locks. The acquire statement should check existence of a row with a given value and insert if not there. The statement should some...

Apply a Mask to Format a String in SQL Server Query/View

Is there a neat way to apply a mask to a string in a SQL Server query? I have two tables, one with Phone number stored as varchar with no literals 0155567890 and a phone type, which has a mask for that phone number type: (##) #### #### What is the best way to return a string (for a merge Document) so that the query returns the fully f...

More efficient way of querying for this data?

I have a table with some data in it: ColA | ColB | ColC ------+------+------ 1 | A | X 2 | A | Y 3 | B | Y 4 | C | Y 5 | C | Z 6 | D | Y 7 | D | Z I want to query to get all of the rows where ColB and ColC as a pair match a condition: SELECT * FROM [Table] WHERE (ColB = A AND...

Visual studio 2010 database project and code generation

Hi, I'm trying to use the database project in VS2010, but my setup is a bit different from standard and I can't find an easy way to get it to work. I have a "model" project which contains some xml model definitions of a simple information for an ETL process. As well as the schema for the supplied information, it contains other metadat...

calculate amount on dates difference

i have one table with two columns as shown in picture at the execution of page user enter the start and end date. now what i need to calculate is total amount. for example, if user put start date: 18-jan-2010 end date: 23-jan-2010 then he has 2 dates in first options (20$) and 3 dates in second options (26$) so total...

Can we call a stored proc from a function?

Can we call a stored procedure from a function in SQL? What's the reason? ...

How to call Stored Procedure using Report Builder 1.0?

I'm using SQL Report Builder and I would like to call the stored procedures that were already built. SSRS allows me to do this but since the company's requirement is to build a report model to allow users to do their ad-hoc reports, I need to find a way to include these stored procs written to populate some of the tables. Can anyone ple...

Coloring sql reporting services report depending on the change of value of a certain field

Hey guys, I have an SSRS report that looks something like this: Column1 Column2 Row1 2 A Row2 2 B Row3 2 C Row4 6 A Row5 11 E how can I color the rows with the same value in Column1 with the same color? for example Row1 to Row3 would have one color, Row4 would have a different color,...

MySQL problem! Needs to select unique value from one row only

Hi Everyone:) I'm creating this app where it's important to register if a person is active or not on the current day. My table structure looks like this: | Field | Type | Null | Key | Default | Extra | +-----------+-------------+------+-----+-------------------+----------------+ | id | int(11) |...

Wildcards in MS Access SQL

Hi, I've written this SQL query in MS Access: SELECT * FROM Students WHERE name like '_a*' Which produces no results, even though I have names like danny and sara in the Students table. THe '_' wildcard doesn't seem to work. BTW, like '*a*' does return all names with a in them. And ideas? ...

Need examples for Unicode SQL queries.

Hi, I need few examples for Unicode SQL queries. Also, i need to understand fully about Unicode. Pls help. ...

Poco: SQL select return no tuples. How do I detect that

I am using Poco C++ libraries for accessing the database. Following is a query from the Poco::Data docs ses << "INSERT INTO FORENAME VALUES(:name)", use(aName), now; Given an SQL select query if it returns no tuples how do I detect that? Is there a flag which is set by the data base? ...

nested select mysql

hi i want write this sql select statment in mysql v 3.23 select * from radacct where username in (select username from radcheck where Attribute= 'max-weekly-session'); but say ERROR 1064: You have an error in your SQL syntax near 'select username from radcheck where Attribute= 'max-weekly-session')' at line 1 in mysql v 5 this is ...

ASP.net equivalent of ASP's rs.getRows()

In classic ASP, you can dump a recordset into an array using getRows(). This is a lot faster way of looping results, and frees up the recordset earlier. Is there an equivalent in ASP.net (c#?). I've had a look on google and all I can find is a bunch of ugly while loops that dump the rows in an array list, is there a nicer way of doing...

How to make EF execute Insert Queries in the right order?

Hello, I am using the Entity Framework with a MySQL server because I want to be able to do nice and easy LINQ queries againy my MySQL database. I have a very simple problem and I'm frustrated because I can't believe that the EF is making such a horrible mistake. To simplify, I have parent and child classes, and I want to execute two in...

ASP.net - Unsure on how to generate table

Given the following HTML: <asp:content id="Content1" contentplaceholderid="mainContent" runat="server"> <div class="scrollRow"> <table width="100%"> <tr> <td width="25%">Site name: <b>My site</b></td> <td>Created on 12th Aug 2010</td> <td align="right"><button onclick="doRevert(1)">Revert...

Convert string to DateTime in SSIS

The data from source has string data type and sometime has invalid dates, empty column ('') I want to check whether it is valid date and convert string to date time. How can i do this in SSIS? My string value is already formatted as mm/dd/yyyy. ...

Need help in understanding JOINS in SQL

Hi All: I was asked the below SQL question in an interview. Kindly explain how it works and what join it is. Q: There are two tables: table emp contains 10 rows and table department contains 12 rows. Select * from emp,department; What is the result and what join it is? ...