sql

LINQ Query with dynamic number of boolean ANDs

I am working on a search web page for my site. The requirements state that users can enter text for any combination of 9+ fields and the search should do an 'AND' match when querying the database. I could fairly quickly write this as a stored procedure using 'ISNULL' but I'm trying to figure out how to accomplish the same thing in LINQ...

SQL Server 2008 - Concatenate String

Hi All, I have the need to take the results of a query per line item and build a semi-colon delimited list of materials that make up that item. Schema Makeup: Tables: LineItems (Unique Item Listing) LineItems_Materials (Many to Many) Materials (Unique Material Listing) Line Items: ID|LineItem 1|'1A.1' LineItems_Materials: ID|LineIt...

How do I query a SQL database to return the first "page" containing the specified data?

------------------------ | | A | | ------------------------ | | B | | ------------------------ | | C | | ------------------------ -----Page 1 | | D | | ------------------------ | | E | | ------------------------ | | F | | ------------------------ --...

How to update SQL table with CSV data?

I am trying to update one of my SQL tables with new columns in my source CSV file. These CSV records in this file are already in my SQL table, but they are lacking some of the columns from this CSV file. I already added the new columns to my SQL table. But now I just need to import the data from the new columns. How can I do this b...

selecting data between a certain date range where date range is a varchar

i have a varchar reporttime that has the date stored. dont ask me why it is a varchar i am doing this to get data between two dates: select rowid from batchinfo where CONVERT(DATE, reporttime, 103) between '2010-07-01' and '2010-07-31' and it is not working what am i doing wrong? btw this is what the data looks like: rowid da...

ODBC error in PHP: "No tuples available at this result index"

Been looking for this on Google for a while, but still looking. Couldn't turn up anything on it. Using PHP to query MS SQL Server via ODBC. Code is below: (I've watered it down to bare-bones as I've tried to debug this) $SQL=<<<HEREDOC DECLARE @weekStart SMALLDATETIME; SET @weekStart = DATEADD(d,0, DATEDIFF(d,0,GETDATE())); S...

mysql LAST_INSERT_ID() is causing some SQL problems when passing back value retrieved...

I need some help figuring out why the following scenario does not work. I'm trying to retrieve a value from the last updated ID in mysql, then pass that value via javascript over to an ajax call which calls a .php page, which also calls another function "ZEND_emaiL" in a different php page. In the very first php page that retrieves the...

SQL Server: finding the bad data

How do I select all rows except for ones that where I get an error calling CONVERT on one of the columns? For example, I am doing this: SELECT rowid FROM batchinfo WHERE CONVERT(DATE, reporttime, 101) between '2010-07-01' and '2010-07-31'; And I am getting errors for some of the values. I have two questions: How can I skip the r...

Why does Windows Search query return DBNull for long non-empty string properties?

I have created a Windows Search string custom property that shows up fine as a column in Windows Explorer. In C# I issue the following SQL query: SELECT System.ItemPathDisplay, System.ItemName, My.Custom.Property FROM SystemIndex WHERE CONTAINS(My.CustomProperty, 'blah') The resulting OleDbDataReader correctly returns a list of the fi...

get next max problem with A999 > A1000

Some product serial numbers are of type varchar and have a letter indicating the type followed by a number. The numbers are 0 padded up to 5 digits and we are approaching 'A100000'. For the letters that have less than 100000 items they still want 0 padding up to 5 digits, and the letters that have more that 100000 to have more digits u...

Is there a comparison table showing differences between MySQL, SQLite, and PostgreSQL SQL implementations?

I believe I my understanding is correct that there is a standard SQL. I'm assuming that MySQL, SQLite, and PostgreSQL all have variable support for the standard. Can anyone point me to a comprehensive comparison table that shows the differences? ...

Count of a column with different rows

I want to join two tables (below) which i get. But then I want to do a count to see how many times each job_category is shown when contactId > 0 Any Help would be appreciated! Tablel : | JobPositionId | JobPositionName | JobDescriptionId | JobCategoryId | ContactId ----------------------------------------------------------------------...

Fastest way to populate a Db

I have an excel spreadsheet with products and categories with a many to many relationship and i need to populate the db with it. I am searching for a quick way to enter this data in and have the join table have all the correct info. I have phpmyadmin but it seems to be a bit slow unless there is a shortcut. Another approach i was thinkin...

Python client for MSSQL, with encrypted connections?

I am looking for a Python client for MSSQL, but one that supports encrypted connections to a remote MSSQL server. Can someone recommend a technique for using Python to read from MSSQL, over an encrypted connection? ...

How to return "row number" of first occurrence, SQL?

(row number not stored in db) ------------------------ | | A | | (1) ------------------------ | | B | | (2) ------------------------ | | C | | (3) ------------------------ -----Page 1 | | D | | (4) ------------------------ | | E | | (5) ------------------------ |...

Getting the Next Available Row

How can I get a List all the JobPositionNames having the lowest jobPositionId when ContactId = 1 Tablel : | JobPositionId | JobPositionName | JobDescriptionId | JobCategoryId | ContactId --------------------------------------------------------------------------------- 1 | Audio Cables | 1 | 1 ...

SQL query for most recent date and constrained by another column

Hello, I have a table (PAT_PROCEDURES) with three columns: patient_id, procedure_id, procedure_date, and token_id that stores records about patients and procedures they've undergone as well as the procedure's date; token ID is a special numeric identifier. I also have another table (PAT_TOKENS) with three columns patient_id and token_...

Select all projects that have matching tags

I'm trying to find the most efficient way of dealing with this but I must tell you front-head I've made a mess of it. Looked around SO and found nothing of relevance so here it goes. How to select all projects that have similar tags to the desired project? Take this table for example: (sql code to recreate tables bellow) project 1 -...

Database Design Help: Whose kid is this anyway...

I am building my wife a Contacts Manager program as a fun exercise in learning Silverlight 4. It will track peoples Addresses, Phone Numbers, Emails, Special Occasions(Birthday, Anniversary, etc) Along the way I hit a minor road bump while designing the Database. She would like to be able to group Contacts(people) by Family so I creat...

SSRS 2005 Get Next Record Value

Hello, How to get Next Record value in SSRS 2005? In SSRS 2005 has previous function but it has not NEXT function. Any other way to implement this function? Prompt reply will be appreciated. Thanks, Dhruval Shah ...