sql

Binding SQL table to DataGridView in WPF

How can I bound SQL table to datagridview in WPF? ...

Using @@IDENTITY in SQL on a specific table

How can I get the @@IDENTITY for a specific table? I have been doing select * from myTable as I assume this sets the scope, from the same window SQL query window in SSMS I then run select @@IDENTITY as identt It returns identt as null which is not expected since myTable has many entrie in it already.. I expect it to return the...

is there an advantage to varchar(500) over varchar(8000)?

I've read up on this on MSDN forums and here and I'm still not clear. I think this is correct: Varchar(max) will be stored as a text datatype, so that has drawbacks. So lets say your field will reliably be under 8000 characters. Like a BusinessName field in my database table. In reality, a business name will probably always be under (pul...

searching for address matches using sql server 2008 full text search

Hi, I am not sure how to search for address matches using sql server 2008 full text search. This is what I tried but it doesn't return any records. TableA ------ Address1 Address2 City State Zip All the above columns in the table are full text indexed. Let's say if the user enters "123 Apple street FL 33647" and I have a record in th...

How to ignore bad characters in a SQL query

The short story is I have a SQL Server DB with varchar fields instead of datetime (don't ask, it's a long story and can't be fixed). Somehow we've recently been getting weird / random characters inserted in these fields instead of what should be there (either NULL, '' or YYYY-MM-DD). Something like this: '?+x' with high-bit ascii charact...

PostgreSql - Constraint Not Applied by a Trigger

I have a table defined like this: CREATE TABLE A ( begin date, end date, CONSTRAINT ordered_dates CHECK ( begin <= end) ) ..and 2 triggers associated : trigger1 on BEFORE update trigger2 on AFTER update In the trigger1, there's an insert in a second table B by computing the interval (=end-begin). If the constraint ordere...

update records only when ID matches

How would I update data in a table in a separate database based on the records in the current database? For instance I want to update the field "status" in the database called "database_old" with the value contained in the database "database_new" . My current data exists in the database "database_new". I want to only update records in ...

Aggregate function in an SQL update query?

I'm trying to set the value in one table to the sum of the values in another table. Something along these lines: UPDATE table1 SET field1 = SUM(table2.field2) FROM table1 INNER JOIN table2 ON table1.field3 = table2.field3 GROUP BY table1.field3 Of course, as this stands, it won't work - SET doesn't support SUM and it doesn't support ...

How can I do a compare when the second is a sub select that returns multiple values?

Here's my SQL statement: SELECT DISTINCT a.* FROM OWU_Nomination as a, Merchants as b WHERE a.CallFlag = 'False' AND a.nominatedDate < DateAdd(hour, -24, getdate()) AND a.email != (SELECT c.Email from Members as c where c.MemberID = b.MemberID) The problem here is that the sub select after a.email != returns multi...

How to sort within a sql view

I've created a sql view and I need to sort the results of select by using the ORDER BY on 4 fields, but I'm getting message that ORDER BY cannot be used in views unless I use TOP. Can someone explain why TOP is needed, and does someone have a workaround for sorting in a sql view? Thanks. ...

Performance of updating one big table using values from one small table

First, I know that the sql statement to update table_a using values from table_b is in the form of: Oracle: UPDATE table_a SET (col1, col2) = (SELECT cola, colb FROM table_b WHERE table_a.key = table_b.key) WHERE EXISTS (SELECT * FROM table_b WHERE ta...

Report Builder 3.0 CTP

I have downloaded MS SQL Server Report Builder 3.0 CTP recently. I am bit confused and have following questions: Can I use Report Builder 3.0 with MS SQL server 2008 Express with Reporting services (NOT MS SQL Server 2008 R2 CTP)? Is there any time limit is attached with usage of Report Builder 3.0 CTP, as it is CTP version? Generally ...

In MySql, find strings with a given prefix

In MySql, I want to locate records where the string value in one of the columns begins with (or is the same as) a query string. The column is indexed with the appropriate collation order. There is no full-text search index on the column though. A good solution will: Use the index on the column. Solutions that need to iterate over all ...

Can I use free SQLServer Express in commercial app

Can I use free SQLServer Express in my commercial windows project? Are there any license issues? How many nodes it supports in multiuser environment ? ...

Difference between Temp Table and Table Variable In SQL 2005

Hi Can somebody explain me the difference between Temp table and table variable in SQL server 2005? ...

limitation for client nodes in free SQLServer Express

is there any limitation for client nodes in free SQLServer Express. How many nodes it supports in multiuser environment ? ...

Need help with SQL

I have the following query that seems to do what I want it to, but I think there may be a shorter way CREATE TABLE #userScoreForComment ( comment_id int, points int ) INSERT INTO #userScoreForComment SELECT comment_id, SUM(Scores.points) AS Points FROM Comments INNER JOIN Scores ON Comments.username = Sc...

service broker catalog views - permissions required to query

Hi, I have discovered that querying catalog views (e.g. sys.conversation_endpoints) under my non-sa/restricted user will succeed but always return an empty set. What permission(s) do I need to grant my SQL login to be able to successfully query service broker catalog views..? Thanks in advance, Tamim. ...

How to copy an ntext column's value to a new non-null column

I have a table that has an ntext column defined as [value1] [ntext] NOT NULL. I want to add another ntext column to this table that is basically a copy of this column's values (they don't need to stay in sync). To do this, I am using the following SQL: ALTER TABLE [table] ADD [value2] [ntext] NULL UPDATE [table] SET [value2] = [value1] ...

Mysql: Which to use when: drop table, truncate table, delete from table.

List the differences between the following MySql commands. drop table tablename; truncate table tablename; delete from tablename where 1; Also from your experiences please tell me typical usage scenario for each. ...