sql-server

Can I execute an SQL Server DTS package from a Python script?

I currently have a number of Python scripts that help prep a staging area for testing. One thing that the scripts do not handle is executing DTS packages on MS SQL Server. Is there a way to execute these packages using Python? ...

what's wrong with this ADODB connection string to sql server 2005

I'm working on populating a combobox in visual studio 2005 using vb and I'm stuck on the connection string part. I should mention i'm connecting to a SQL Server 2005 instance. Here is what i have: Dim gDBA As ADODB.Connection Dim records As ADODB.Recordset gDBA = New ADODB.Connection gDBA.Open("Server=e-13;Database=subscribers;User...

Way of searching 30,000 SQL Records

I am about to make a simple search facility on my website, where a user will enter around 2-4 keywords which will get searched in two columns in a table in my MS SQL database. One column is a varchar (50) called title and one column is a varchar(2500) called description. There will be about 20,000-30,000 records potentially at any one ti...

Writing a complex trigger

I am using SQL Server 2000. I am writing a trigger that is executed when a field Applicant.AppStatusRowID Table Applicant is linked to table Location, table Company & table AppStatus. My issue is creating the joins in my query. When Applicant.AppStatusRowID is updated, I want to get the values from Applicant.AppStatusRowID, Applicant....

What is the difference between TEMPORARY TABLE and TABLE VARIABLE in SQL 2008?

What is the difference between: CREATE TABLE #temp ( [ID] INT) INSERT INTO #temp SELECT ... and DECLARE @temp TABLE ( [ID] INT) INSERT @temp SELECT ... in SQL Server 2008? ...

What is the preferred merge method for SQL Server 2005?

I have mainly been using the Exists Method for merging a row into a table but I am considering switching to the Row Count Method. Is there any reason not to? Exists Method If Exists(Select * From Table Where ID = @ID) Begin Update Table Set Value = @Value Where ID = @ID End Else Begin Insert Into Table (Value) Values (@Va...

Subquery using Exists 1 or Exists *

I used to write my EXISTS checks like this: IF EXISTS (SELECT * FROM TABLE WHERE Columns=@Filters) BEGIN UPDATE TABLE SET Columns=VALUES WHERE Columns=@Filters END One of the DBA's in a previous life told me that when I do an EXISTS clause, use SELECT 1 instead of SELECT * IF EXISTS (SELECT 1 FROM TABLE WHERE Columns=@Filters) BEG...

How to create DB in SQL Express using SQL commands?

I am reading a book on SQL and it gives me scripts to run to create a database. But I have only SQL Express 10, which doesn't look like has tools to run SQL commands. Is there any way to run the scripts? ...

TSQL- Rollup SQL 2005

I have the following example code: create table Details( name varchar(20), age int, weight int, recordDate Datetime) --insert data ..query: SELECT a.name, a.age, a.recordDate, a.weight - (SELECT b.weight FROM Details WHERE b.recordDate = dateadd(dd, -1, a.recordDa...

how to pass a null value to a rdoQuery.rdoParameter in VisualBasic 5

I have a visual basic 5 project, using Microsfot Remote Data Object 2.0 I have the following code: Set ps = grdoCon.CreateQuery("Resolucion_ValidaCorrelatividad", SQL) ps(0).Direction = rdParamReturnValue ps(1).Direction = rdParamInput ps.rdoParameters(1) = vbNull ps.Execute it gives me the following error: (40002) 22005: [Micr...

DateTime manipulation in SQL Server EXECUTE sp_executesql

I am trying to do the following: EXECUTE sp_executesql N'SELECT TOP 10 * FROM dbo.Items WHERE DateCreated BETWEEN @start AND @end' , N'@start DATETIME, @end DATETIME' , @start = '20091001' , @end = GETDATE() --problem is caused by this line Error: Msg 102, Level 15, State 1, Line 5 Incorrect syntax near ')'. I need to...

Updating a summary table based on 2 other tables.

Commisions (commisionID INT, EmployeeID, amount INT, created Datetime) Sales (saleID INT, EmployeeID, amount INT, created datetime) The summary table: Employee (employeeID, totalCommisions INT, totalSales INT, created DateTime) There can be 0 or more rows per employee in both Commissions and Sales tables. Query#1 The query is to u...

COLLATION Conflict For Equal To Operation Sql Server 2000

I have a collation conflict in a stored procedure I am trying to run to send it live... it has been explained here http://stackoverflow.com/questions/1519544/sql-server-2000-dts-cannot-resolve-collation-conflict-for-equal-to-operation Is there a way to fix the issue without writing the COLLATE database_default next to every problem equ...

Bulk Copy from SQL Server to Oracle

I have a requirement for a project to move data from SQL Server to Oracle in bulk mode. There is OracleBulkCopy from DataDirect and ODP .net but to use that I have to first convert the data reader from SQL server into a CSV file and then can export that using bulk copy.This is a very inefficient process and I was wondering if there is an...

SQL's Fallthrough CASE Statement

In C# we can write switch(num) { case 0: case 1: // do something; break; case 2: ............ ........... case n: // do something break; default: //do something; break; } How can I achieve the similar kind of stuff in SQL SERVER ? I am not talking about the simple way of writing CASE in SQL SERVER. I am talking about if...

how to select a particular table from a storedprocedure which returns multiple table?

Hi all, I have a storedproc which has multiple select statement. When it is executed in sql server , it returns multiple tables. I need a query which will select a particular table from the storedproc e.g. sp_help. Please help. ...

ANSI vs. non-ANSI SQL JOIN syntax

I have my business-logic in ~7000 lines of T-SQL stored procedures, and most of them has next JOIN syntax: SELECT A.A, B.B, C.C FROM aaa AS A, bbb AS B, ccc AS C WHERE A.B = B.ID AND B.C = C.ID AND C.ID = @param Will I get performance growth if I will replace such query with this: SELECT A.A, B.B, C.C FROM aaa AS A JOIN bbb AS B ...

Using SMO, still no go... ConnectionContext.ExecuteNonQuery(script) can't understand "GO"

Hello! SQL Server 2008 Using all the correct references I dare say: System.Data.SqlClient; Microsoft.SqlServer.Management.Smo; Microsoft.SqlServer.Management.Common; Microsoft.SqlServer.Management.Sdk.Sfc; All compiles with no errors. I have stripped code down to almost zero for easy debugging. Connecting to server alright and so o...

How to move the database from one server to another server?

Using SQL Server 2005 I attached the database in Windows authentication Mode, then it detach the database, and then i try to attach the same database in sql authentication mode. It showing error as "cannot create a sysindex" The database was created in windows authentication mode, It is working in all windows authentication mode. It wa...

How to validate sql query syntax?

java 1.4 Sql server 2000 i am taking input of sql query (for validation of field value against values retrieved by executing sql query) from admin user which will be stored in database and later i will executing sql query corresponding to field.Before inserting sql query in database i want to validate its syntax in java code. Fields ...