sql-server

sql 2008 query. I am trying to correct this error message

What is wrong with this code? What would be the correct syntax? SELECT EmployeeID, SUM('More than 2 orders') FROM Orders WHERE EmployeeID >2 GROUP BY EmployeeID Msg 8117, Level 16, State 1, Line 1 Operand data type varchar is invalid for sum operator. ...

Question about inserting/updating rows with SQL Server (ASP.NET MVC)

I have a very big table with a lot of rows, every row has stats for every user for certain days. And obviously I don't have any stats for future. So to update the stats I use UPDATE Stats SET Visits=@val WHERE ... a lot of conditions ... AND Date=@Today But what if the row doesn't exist? I'd have to use INSERT INTO Stats (...) VALUES...

What happens when I create an index on a view? Are there any benefits versus using a table with indexes?

From what I understand the data will be "persisted" (physically stored, not just retrieved when i need it). Is this correct? If so what would be the advantage of using an indexed view versus just using a table? ...

Error at the transport level when sending a request to the server.

Strange System.Data.SqlClient.SqlException Error at the transport level when sending a request to the server. (Provider: Shared Memory Provider, error: 0 - Since both ends of the canal there are no processes.) I've got this exception on my Web Site every time after restarting my SqlServer on simple request like this : if (System.Web....

Combining multiple condition in single case statement in Sql Server

According to the following description i have to frame a case ...End statement in Sql server ,help me to frame a complex case..End statement to fulfil the following condition. if PAT_ENT.SCR_DT is not null and PAT_ENTRY.ELIGIBILITY is null then display display 'Favor' if PAT_ENT.SCR_DT is not null and PAT_ENTRY.EL is equal to No, displ...

What are prepared statements?

What are prepared statements in the context of relational databases? How do they help and when should I consider using them? ...

Migrate MySQL database to Sql Server

I recently encountered a problem in my production database due to MySQL bug. The bug is in the TimeStamp column. To avoid any inconvenience, I want to migrate the database to either Sql Server. Is there any FREE tool to easily and reliably migrate data and table structures? ...

Sql server execute permission; failure to apply permissions

I've just migrated from SQL2000 to SQL2008 and I have started getting an execute permission issue on a stored proc which uses sp_OACreate. The rest of the system works fine with the db login which has been setup and added to the database. I've tried: USE master GO GRANT EXEC ON sp_OACreate TO [dbuser] GO But this fails with the foll...

how to build sql server 2008 datetime object and insert it using perl DBI

How can i build a sql server 2008 datetime object with perl and insert it using the dbi module to specific table could someone provide example ...

MYSQL Download Links.....

I want to download MySQL Database..... Any one can suggest me for best link to download the MYSQL ...

Deploy SMO application to workstation without SQL Server 2008 installed

I am trying to deploy an application that uses SMO on a workstation without SQL Server installed on it. The instance the app is connecting to is SQL Server 2008. The application is failing with: Could not load file or assembly 'Microsoft.SqlServer.Replication, Version 10.0.0.0, Culture=neutral, PublicKeyToken=89845cdc8080cc91' or one ...

DataGridView population+modificaion by SQL Server DB View

I searched StackOverFlow.com for my issue, but could not find any similar/related solution. I have few tables in SQL Server 2005, and have to make use of those tables in my Winform/C# application which is supposed to be an Admin Application where the Administrator will:- 1.Add/Edit users 2.Assign Roles 3.Assign Privileges 4.Zone As...

Finding simultaneous events in a database between times

I have a database that stores phone call records. Each phone call record has a start time and an end time. I want to find out what is the maximum amount of phone calls that are simultaneously happening in order to know if we have exceed the amount of available phone lines in our phone bank. How could I go about solving this problem? ...

What's the Correct name for a Association table (many to many relationship)

What's the Correct or most popular name for a Association table? I've heard Lookup,associative,resolving,mapping and junction table so far? Thank you in advance;-) ...

My tricky SQL Update query not working so well.

I am trying to update a table in my database with another row from another table. I have two parameters one being the ID and another being the row number (as you can select which row you want from the GUI) this part of the code works fine, this returns one column of a single row. (select txtPageContent FROM (select *, Row_Number()...

SQL Server Querying An XML Field

I have a table that contains some meta data in an XML field. For example <Meta> <From>[email protected]</From> <To> <Address>[email protected]</Address> <Address>[email protected]</Address> </To> <Subject>ESubject Goes Here</Subject> </Meta> I want to then be able to query this field to return the following results F...

Set of Tools to optimize the performance in general of SQL Server

Hi, I know there are things out there to help to optimize queries, ect... but is there anything else, something like a full package that can scan your database and highlight all the performance issues, naming conventions, tables not properly normalized, etc? I know this is the job of a DBA and if the DBA is good, he shouldn't need a t...

triggers for generating userID based on user's information.

I have complaint table 1. tblProfile with columns userId | name | age | address | mobileno | 2. tblUserId with columns userId | role | status now when user fills the form I want to insert one row in tblProfile, before inserting a new row I want to create userId by combining starting letters of name and mobile no and then insert into tbl...

Effective way to keep SqlDecimal precision compatible for SqlBulkCopy

I've encountered the following InvalidOperationException when trying to insert a value of 91 to Numeric(19,4) row into an MS SQL table. {"The given value of type SqlDecimal from the data source cannot be converted to type decimal of the specified target column."} Inner Exception: {"Parameter value '91.0000' is out of range."} I've dis...

Faling to connect to Database due to database in recovery

I am using SQL Server 2008, developer edition. I connect to my database from my asp.net mvc application using Linq2SQL. I noticed that my database went into recovery mode about 4 times in a span of a month. I am running a few complext Linq2SQL queries. When database is in recovery mode, my asp.net mvc application is going off line as it ...