sql-server

SQL Complex Select - Trouble forming query

I have three tables, Customers, Sales and Products. Sales links a CustomerID with a ProductID and has a SalesPrice. select Products.Category, AVG(SalePrice) from Sales inner join Products on Products.ProductID = Sales.ProductID group by Products.Category This lets me see the average price for all sales by category. However, I only ...

SQL Server Return 1 Row Per Boat

Basically, what I want to do is join 4 tables together and return 1 row for each boat. Table Layouts [Boats] id, date, section, raft [Photos] id, boatid, pthurl, purl [River_Company] id, sort, company, company_short [River_Section] id, section Its very simple as far as structure, however, I've having the time of my life try...

SQL server deadlock between INSERT and SELECT statement

Hi! I've got a problem with multiple deadlocks on SQL server 2005. This one is between an INSERT and a SELECT statement. There are two tables. Table 1 and Table2. Table2 has Table1's PK (table1_id) as foreign key. Index on table1_id is clustered. The INSERT inserts a single row into table2 at a time. The SELCET joins the 2 tables. (it'...

Best solution for reporting database

Here is the situation: There is a transaction intensive database - used for both routine transactions and reports. I was wondering if I could isolate these two operations and 2 independent databases, so reports could run off of one database and all the transactions could occur in another one. This would improve performance for the OLTP ...

Count times ID appears in a table and return in row.

SELECT Boats.id, Boats.date, Boats.section, Boats.raft, river_company.company, river_section.section AS river FROM Boats INNER JOIN river_company ON Boats.raft = river_company.id INNER JOIN river_section ON Boats.section = river_section.id ORDER BY Boats.date DESC, river, river_company.company Returns everything I need. But how wo...

I Need Help Fixing My Small Time Sheet Table - Relational DB - SQL Server

I have a TimeSheet table as: CREATE TABLE TimeSheet ( timeSheetID employeeID setDate timeIn outToLunch returnFromLunch timeOut ); Employee will set his/her time sheet daily, i want to ensure that he/she doesn't cheat. What should i do? Should i create a column that gets date/time of the system when in...

How can we check that table have index or not ?

Hi, How can we check that table have index or not ? if have how to find that index for a particular column for a table? Regards, kumar ...

get column names from a table where one of the column name is a key word.

Im using c# .net windows form application. I have created a database which has many tables. In one of the tables I have entered data. In this table I have 4 columns named key, name,age,value. Here the name "key" of the first column is a key word. Now I am trying to get these column names into a combo box. I am unable to get the name "key...

Which is the most suitable method for Data Access in Silverlight 3?

We are planning to move to Silverlight 3 for application development because we want to take advantage of more flexible UIs and easier deployment. We have previously used Winforms with ADO.Net and SQL Server for data driven applications. I've briefly looked at some of the options for data access with silverlight such as Entity Framework...

SQL Server (Not Express) + Visual Studio Express (vb.net) - Connection possible?

Hi, I couldn't find a quick answer on the official pages, is it possible to write VB projects in the express edition of Visual Studio that connect to a SQL Server that is not the included 'Express' server ? Any hints appreciated :-) ...

Login Dialogue box when deploying a report for sql server 2008 reporting services

hi, I have created a new report server project using the wizard in Business Intelligence Development Studio, which i started as "run as administrator" (since i am using win 7). I have configured the reporting service and I can access the reporting server from the Internet explorer. I can also upload report files *.rdl. I can also run t...

SQL Query slow in .NET application but instantaneous in SQL Server Management Studio

Here is the SQL SELECT tal.TrustAccountValue FROM TrustAccountLog AS tal INNER JOIN TrustAccount ta ON ta.TrustAccountID = tal.TrustAccountID INNER JOIN Users usr ON usr.UserID = ta.UserID WHERE usr.UserID = 70402 AND ta.TrustAccountID = 117249 AND tal.trustaccountlogid = ( SELECT MAX (tal.trustaccountlogid) FROM TrustAccountLog AS...

Creating an insert query (error of foreign key constrant)

I want to move data from one database's table to another database's table. It is giving me a foreign key error. Please tell me how I can insert all those data which is valid except those rows who don't have a foreign key. I am using SQL Server 2005 My query is : SET IDENTITY_INSERT City ON INSERT INTO City ([cityid],[city],[countr...

SQL Server Common function for getting max(id)

Hi All, In my application many I time we use MAX(). How can I write a common function where I can pass table name and column name and get MAX(). I mean single function for any table/field. Thanks, Tanmay. ...

Controlling Trigger Execution When Bulk Importing Data

Hi In bulk insertion only in the last record trigger is executing. If I bulk insert 10 records the trigger is running only for the 10th record. But I need trigger to run on all 10 records. Please help me with an example ...

How to track number of changes occured in a column? T-SQL - SQL Server

For example, i have a column named EmployeeName. Every time a user changes/fix his name, i need to keep a count. If he changes his name twice, then count is 2. Also, i need to store the time of every change employee makes on EmployeeName e.g. if the name essentially is James and time created is 9:00 AM and then employee changes to John ...

Why is Set Command is blank

I am new to T-SQL and wanted to know why the following works and does not raise and error: I have : DECLARE @aVARCHAR(200), @b VARCHAR(100) SET @a = (Some complicated SELECT Statement) SET @b = 'ALTER TABLE abc DROP CONSTRAINT ' + @a; <-------- expected it to contain string. Exec(@b); The first set has a complex select statement wh...

SQL SERVER SSAS: How do I handle a NULL date value in my fact table, so I can process my time dimension without errors?

Hello! I have a fact table that has a column with dates loaded from an MS Access source. The thing is, some of the values are NULL and the SSAS won't let me refer my DATE dimension to it. Is it better to solve it at the SSIS stage or is there some solution at the SSAS? Thank you very much for you help. ...

Need to automatically Highlight the keywords in the text box using code behind c#

Hi I m retrieving a text from SQL DB based on the Search criteria i give and displaying in the Textbox in asp.net. I need to highlight the words given in the search criteria in the displayed text. For example : If i give "need" all the word "need" in textbox that is retrieved and displayed should be highlight in yellow color. Provide...

SQL 2000 Not Supported by .NET Framework Data Provider for SQL Server in VS2010's Server Explorer Data Connections

Just tried creating a data connection to a SQL 2000 database in VS2010's Server Explorer using a .NET Framework Data Provider for SQL Server (versus OLE) and found that it didn't work. VS2010 complained that I had to use SQL Server 2005 and up. This used to work in VS2008 (using .NET Framework Data Provider for SQL Server instead of th...