sql-server

How to run a ssis package using a sql statement?

i'm using Sql Server 2008. There are options to run from command line. Is there a way to execute an ssis package using sql statement? -Vivek ...

SQL Server Efficiently dropping a group of rows with millions and millions of rows

I recently asked this question: http://stackoverflow.com/questions/2519183/ms-sql-share-identity-seed-amongst-tables (Many people wondered why) I have the following layout of a table: Table: Stars starId bigint categoryId bigint starname varchar(200) But my problem is that I have millions and millions of rows. So when I want to de...

Missing Microsoft.SQLServer dlls

Ok, I installed the Microsoft SQL Server 2005 Backward Compatibility Components here file:///C:/Users/davids/AppData/Local/Temp/instructions_enu.htm but I guess these dlls are not in this. Anyone know where the heck I can get these? Yes, I'm running SQL 2008 so they are missing because they're for 2005. Microsoft.SqlServer.ConnectionI...

SQL Server - Compare int values in a select clause

This is what I thought would be a simple select clause, however the following is giving me grief! I am using SQL Server 2008. Basically I want to compare two integer values and return the boolean result in the select clause. Here is a simple example: DECLARE @A INT DECLARE @B INT SET @A = 1 SET @B = 2 SELECT @A = @B Currently the on...

Is it possible to a db constraint in for this rule?

Hi folks, I wish to make sure that my data has a constraint the following check (constraint?) in place This table can only have one BorderColour per hub/category. (eg. #FFAABB) But it can have multiple nulls. (all the other rows are nulls, for this field) Table Schema ArticleId INT PRIMARY KEY NOT NULL IDENTITY HubId TINYINT NOT NU...

Why would a SQL query JOIN on the same table twice with the same condition?

I'm working on changes to a SQL Server v8 database developed by someone else, and have found something that seems (based on my limited SQL knowledge) strange and pointless. One of the views has a query that does a LEFT OUTER JOIN twice on the same table with the same condition. Is there any reason for doing this? The query is below. See...

SQL 2000 (MSDE) Hangs When It Receives an Erroneous Query from a Classic ASP Web Application

I have a SQL interface page in my classic ASP web app that allows admin users to run queries against the app's database (MSDE 2000) - it simply consists of a textarea that the user submits and the app returns the resulting list of records as below Dim oRS Set oRS = Server.CreateObject("ADODB.Recordset") oRS.ActiveConnection = sConnectio...

Getting "[Microsoft][ODBC SQL Server Driver][SQL Server]Incorrect syntax near 'Microsoft.'

Hi Experts, I'm getting an error, "[Microsoft][ODBC SQL Server Driver][SQL Server]Incorrect syntax near 'Microsoft.' Here is the code: Dim conn As ADODB.Connection Dim rst As ADODB.Recordset Dim stSQL As String Public Sub loadData() 'This was set up using Microsoft ActiveX Data Components version 6.0. 'Create ADODB connectio...

SQL Server in ASP.NET application getting unstable after a certain period

Hello, I have an ASP.NET 2.0 application that I made to keep track of disruption reports about our public transport system. The architecture is pretty straight-forward; an SQL Server Express 2008 database, ADO.NET and a DataSet/DAL with a few methods to access the database. There is a set of .aspx pages for the UI in use by our dispatche...

How to lock a table for inserting in sql?

Hi, I have a web application in which I have a page named 'Data'. Many people will try to insert data into the table at a given time. So the reference no other than the primary key will get duplicated which should not be permitted. For inserting the data into the DB table, I am using a stored procedure in SQL. In my vb.net web applicati...

How can I connect to a principal database when a failover occurs in SQL server 2005?

How can I connect to a principal database when a failover occurs in SQL server 2005 using TSQL.....after failover a pricipal database becomes mirror but still how can i connect to the new pricipal using SQL command ...

Atomic UPSERT in SQL Server 2005

What is the correct pattern for doing an atomic "UPSERT" (UPDATE where exists, INSERT otherwise) in SQL Server 2005? I see a lot of code on SO (e.g. see http://stackoverflow.com/questions/639854/tsql-check-if-a-row-exists-otherwise-insert) with the following two-part pattern: UPDATE ... FROM ... WHERE <condition> -- race condition risk...

Quick / Built-in method for detecting table change in SQL Server?

Is there a quick and easy way of telling if a table has changed in SQL Server? (I'm using SQL Server 2005). Something like an incrementing ID somewhere that updates on each INSERT, DELETE or UPDATE that I can keep track of. I noticed there is a sys.objects.modify_date column for each table, but I don't think it's quite what I want becaus...

Searching Week-wise/Month-wise record counts(number) and the StartDate+EndDate(datetime) of the Week/Month with Search between two Dates

I have a question in connection to this question earlier posted by me:- http://stackoverflow.com/questions/2452984/daily-weekly-monthly-record-count-search-via-storedprocedure I want to have the Count of Calls on Weekly-basis and Monthly-basis, Daily-basis issue is resolved. ISSUE NUMBER @1:Weekly-basis Count of Calls and Start-Date a...

Error creating a table : "There is already an object named ... in the database", but not object with that name

Hi, I'm trying to create a table on a Microsoft SQL Server 2005 (Express). When i run this query USE [QSWeb] GO /****** Object: Table [dbo].[QSW_RFQ_Log] Script Date: 03/26/2010 08:30:29 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO SET ANSI_PADDING ON GO CREATE TABLE [dbo].[QSW_RFQ_Log]( [RFQ_ID] [int] NOT NULL...

conditions on count in a select

Hi, i have a table like this: Table(MissioneID, Type) Type can be 1,2 or 3 i have to count missions by type value: ex. if table's content is: MissioneID Type 1,1 1,2 1,1 2,3 1,2 The result of query is MissioneID,Count1,Count2,Count3 1, 2,2,0 2,0,0,1 How can i do? thanks ...

Creating an index with a where clause - SQL SVR 2005

I have recently discovered the ability to use WHERE clauses within indexes in SQL Server 2005. I would like to optimize some queries, and was hoping to get some feedback. The table of interest contains 2 float columns, [long] and [short]. These columns could be 0 in 20-40% of rows. There are several stored procs that query this table...

Evaluation of CTEs in SQL Server 2005

I have a question about how MS SQL evaluates functions inside CTEs. A couple of searches didn't turn up any results related to this issue, but I apologize if this is common knowledge and I'm just behind the curve. It wouldn't be the first time :-) This query is a simplified (and obviously less dynamic) version of what I'm actually doing...

Update table with index is too slow

Hi, I was watching the Profiler on a live system of our application and I saw that there was an update instruction that we run periodically (every second) that was quite slow. It took around 400ms every time. The query includes this update (which is the slow part) UPDATE BufferTable SET LrbCount = LrbCount + 1, LrbUpdated = get...

Php/MySQL to ASP.NET/SQL Server, Suggest if its worth the trouble.

We have been using PHP/MySQL for our web application which has been growing a lot, the database is around 4-5GB and one of the table is 2GB sometimes, hence slowing down whenever any queries to that table is called. Should we just try to optimize, or are we using MySQL above its limit? Will switching our web app to .NET/SQL Server reso...