sql-server

SQL Express 2005/2008 Concurrent Connections

How many concurrent connections do the express editions allow? My front end uses standard ADO.Net code where I open the connection to the server, get my data, and then close the connection. Am I right in saying that as soon as the connection is closed, it then allows this connection to be opened by another user? ...

Multiple "Default" instances in SQL Server cluster? (AKA multiple clustered instances without requiring an instance name to connect)

I'm setting up multiple SQL instances on an active/active cluster, and on our existing SQL Cluster, the cluster name is SQLCLUSTER, but we access the instances as SQLCLUSTERINST1\Instance1, SQLCLUSTERINST2\Instance2, etc. Since each instance has its own IP and network name anyway, can I install SQL as the "Default" instance on each netwo...

SQL Server 2005/2008 International Real-Time Availability

My company recently opened an office in Singapore. I work on the web application we use internally to manage the company, using a SQL Server 2005 back-end. Because of slow access over the net from Singapore, we're shipping them a server that will host a local copy of the web app and database and we want to keep their local version of t...

TSQL. Get Bitwise total for many columns in a row

I have a table that has 4 sets of 25 columns in a BIT concept. Actually field is smallint but it is either 0 or 1 in it's data. Here is my code that is an attempt to get the total for the first group of 25 cols. Declare @rows int , @ID uniqueidentifier , @LocTotal bigint select @rows = ( select count(*) from #t1 ) while @rows > 0 ...

Interpreting SQL Server syntax errors

If there's one thing that I hate about SQL Server, it's the horribly unhelpful error messages. My favorite is "Incorrect syntax near..." because it provides almost no hint as to what's wrong. Are there any tools to get a better idea of what's wrong with the statement? Or does anybody have any other helpful hints for figuring these kin...

Advantages and disadvantages between sql 2005 and sql 2008?

Exact duplicate: Advantages of MS SQL Server 2008 over MS SQL Server 2005? i am a sql developer and i use sql 2005. i want to now to pass to 2008 but i am a little affraid. can anyone gives me some advices about this. should i still continue using sql 2005 or is better pass all my projects to 2008 due to better performace? ...

How to schedule SSIS package to run as something other than SQL Agent Service Account

In SQLServer 2005, is it possible to schedule an SSIS package to run something other than the AQL Agent Service Account? I've got an SSIS package that makes a connection to a db and runs a stored procedure. My criteria is that I will not specify user names/passwords in a package or package configuration, so I want to use integrated au...

How to find what caused errors reported in a SQL Server profiler trace?

I was running a trace on a Sql Server 2005 using the profiler and need to find out what is causing the reported errors. I used the "blank" template, and selected all columns of the following events: Exception Exchange Spill Event Execution Warnings Hash Warnings Missing Column Statistics Missing Join Predicate I noticed a number of ...

Store time of the day in SQL

How would you store a time or time range in SQL? It won't be a datetime because it will just be let's say 4:30PM (not, January 3rd, 4:30pm). Those would be weekly, or daily meetings. The type of queries that I need are of course be for display, but also later will include complex queries such as avoiding conflicts in schedule. I'd rather...

Sum different row in column based on second column value

I have an Orders table (simplified) OrderId, SalesPersonId, SaleAmount, CurrencyId, ... I am attempting to create a report on this table, I'm hoping for something like: SalesPersonId TotalCAD TotalUSD 1 12,345.00 6,789.00 2 7,890.00 1,234.00 I'd prefer not to do a self join (perhaps I'm optimiz...

SQL Server Index Which should be clustered?

I have a number of indexes on some tables, they are all similar and I want to know if the Clustered Index is on the correct column. Here are the stats from the two most active indexes: Nonclustered I3_Identity (bigint) rows: 193,781 pages: 3821 MB: 29.85 user seeks: 463,355 user_scans: 784 user_lookups: 0 updates: 256,516 Clustered Pr...

SQL Server EXCEPT

Here's the situation I'm in. I have a table containing peoples' information. Some of them are imported from another system while some are imported manually. What I would like to do is pull everyone in, but if there is a record entered manually and a record that was imported, I want to select only the imported one (since it is likely m...

Dynamic filename for SQL Server backups?

How can you insert the date in the filename (a dynamic filename) used in a T-SQL backup script? Using SQL Enterprise Manager to create and schedule a backup job, I'd like to edit the T-SQL created to change the filename of the backed up database to be dbname_date.bak (i.e. northwind_5-1-2009.bak). The next time the backup runs, it will...

Storing decimal values in SQL Server

I'm trying to figure out decimal data type of a column in the SQL server. I need to be able to store values like 15.5, 26.9, 24.7, 9.8, etc I assigned decimal(18, 0) to the column data type but this not allowing me to store these values. What is the right way to do this? Thank you ...

Why does merge replication fail on setting a table's LOCK_ESCALATION?

We're having a problem with a merge replication. Our publisher runs SQL Server 2008, while our two subscribers run 2005. Our publisher is trying to send an ALTER TABLE Foo SET (LOCK_ESCALATION) command out to our subscribers. I think I remember reading that this command is new in SQL Server 2008, and if so, it makes sense that the com...

Linq-ToEntities DataSource Assignment Hangs in Winforms

I have a very typical linq-to-entities data binding in WinForms: myGrid.DataSource = myEntities.entity When it reaches that line of code it simply hangs. Similar assignment a different entity work fine elsewhere in the code. The database contains no more than 50 lines of data in all entities (it's a new project) so it's not waiting on...

How to get a dynamic top number of rows?

I want to get the top #nr_of_rows - (int)(#nr_of_rows / 10 - 1) of a table. So like if you have 63 rows, it would return 3 rows, 90 rows would return 10, 85 would return 5, etc.. Of course this can be done in two queries, just wondering if it can be done in one query. If you guys know of a straight sql query, it would be great but ideal...

SQL Statement

I am trying to update a column in my table which was last inserted. I tried creating this stored procedure: CREATE PROCEDURE [dbo].[msp_AssociateEvent] ( @EventId int ) AS UPDATE tblFoodMenus set EventID = @EventId Where FoodMenuID = IDENT_CURRENT(tblFoodMenus) but it gives me this error: Invalid column name tblFoodMenus. Am ...

TSQL - How to check a value against a value in a different column before inserting?

Is there a way to implement a CHECK constraint that checks a value against another value in a different column in the same table? Specifically, I want to ensure that a "checkout" date value to be inserted is greater than the "checkin" date value in the table before inserting the row. I may be missing some details, so please let me know ...

Complicated SQL query for a running total column.

I'm trying to work out a pretty complex query in SQL Server 2008. I'd like some input from SQL experts here. Imagine I had a Payments table with these fields: PaymentID int, CustomerID int, PaymentDate datetime, Amount decimal So essentially, it is a table of payments made by a customer on specific dates. An important thing to n...