sql-server

Connecting to MS SQL Server using python on linux with 'Windows Credentials'

Is there any way to connect to an MS SQL Server database with python on linux using Windows Domain Credentials? I can connect perfectly fine from my windows machine using Windows Credentials, but attempting to do the same from a linux python with pyodbs + freetds + unixodbc >>import pyodbc >>conn = pyodbc.connect("DRIVER={FreeTDS};SER...

how to create xml from xml fragments

I am using SQL Server 2005 and I have a XML Data Type column that stores xml fragments like so in one big table: row 1 ..... <Order date='2009-02-11' customerID='4' /> row 2...... <OrderItem OrderID='6' ItemID='477' quantity='1' /> I would like to create an XML using T-SQL that looks like this from these nodes: <Orders> <Order data...

Updating a collection to db

Hi, This may be a little naive but I just want check my way of doing this is correct. I receive a collection of objects from the UI. I then wish to check those objects against the records in the db. This is what I am doing to Create Update and Delete the received objects. Loop trough received objects - if (id == 0 ) create new record...

any way to detect a TimeStamp column in a DataTable from SQL Server (fillSchema???)

When updating a datatable from a "select * from sometable", I am iterating the columns in the datatable to dynamically create an update or insert statement, based on datatable.rowstate and DataTable.PrimaryKey. However, I can't seem to find any property that indicates whether a column is a TimeStamp in SQL Server and must therefore be i...

SMTP / POP3 / IMAP Mail Server for Windows

I'm looking for a relatively inexpensive (or free) POP3 mail server for Windows Server that will scale well. Compatible with SQL Server would be fantastic. It would also be great if it had a .net class library for performing simple functions like creating/deleting new accounts, adding aliases, etc. Any ideas would be greatly appreciat...

Script SQL Server login with Windows authentication without machine name

I want to write a SQL 2005 script to create a new login that uses Windows authentication. The Windows user is a local account (not a domain one). A local account with the same name exists on many SQL Server machines and I want to run the same script on all of them. It seemed simple enough: CREATE LOGIN [MyUser] FROM WINDOWS However, ...

Is it really better to use normalized tables?

I heard my team leader say that in some past projects they had to do away with normalization to make the queries faster. I think it may have something to do with table unions. Is having more lean tables really less efficient than having few fat tables? ...

How can I use the MS JDBC driver with MS SQL Server 2008 Express?

My configuration: windows XP SP3 JDBC 2005 MS SQL Server 2008 Express, exposed via tcp/ip on port 1433 sqljdbc.jar in class path I tried: try { Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver").newInstance(); con = DriverManager.getConnection("jdbc:microsoft:sqlserver://localhost:1433/SQLEXPRESS2008;databaseNa...

How to move a database using a differential backup?

Hi, I'm using SQL Server 2005. I need to move a database to a new server with minimum downtime. Currently my option is to take everything offline, perform a backup, copy the backup to the new server, restore the backup and bring everything back online. The problem here is that the backup file is about 10Gb, therefore, it takes about ...

Obtaining the Following Error in SQL Server 2005 <The server principal "XYuser" is not able to access the database "Ydb" under the current security context.>

System Specifications... Microsoft SQL Server Management Studio 9.00.4035.00 Microsoft Analysis Services Client Tools 2005.090.4035.00 Microsoft Data Access Components (MDAC) 2000.085.1132.00 (xpsp.080413-0852) Microsoft MSXML ...

An index based on a scalar function applied to a column

I have an user scalar-valued function which takes NVARCHAR(MAX) and returns NVARCHAR(MAX). To increase perfomance of GROUP BY command utilizing this function I wanted to create an index also based on it. But documentation says what CREATE INDEX command only takes columns not expressions, so this is illegal: CREATE INDEX an_index ON a_ta...

selecting top column1 with matching column2

sorry for asking this, but i'm runnin' out of ideas i have this table: [id] [pid] [vid] 1 4 6844 1 5 6743 2 3 855 2 6 888 ... how to i query this eg.table to get the following result: [id] [pid] [vid] 1 5 6743 2 6 888 i want to get the ...

In SqlServer 2008, how would I generalize multiple adjacent polygons?

When you have a table with a Geometry type field (or Geography), you can call the Reduce() function to have the shapes reduced in number of vertices. Works very nicely. However, when sevral of the polygons are adjacent (they share parts of their borders), the reduced polygons do not necessarily do so. Example The SQL batch: CREATE TA...

Improve INSERT INTO - FROM SELECT, SQL Query

Hi, Currently I got this type of query generated by programmation (c#) INSERT INTO TableName (Field1, Field2, Field3) SELECT Field1, Field2, Field3 FROM TableName2 The problem is that the SELECT can have a result of many records (like a million), so it's take many times and the result is an connection timeout. Also, if I separate al...

How can I specify a variable file name using SSIS?

I'm a newbie to using SSIS for data imports - I have a couple of files that I want to import into my database schema, but I'm going to need to run this once every 3 months; the file names change based on the quarter e.g. SKU1QTR will become SKU2QTR. How can I handle a situation like this with SSIS? Is there a way to specify the file ...

Best Way To Prepare A Read-Only Database

We're taking one of our production databases and creating a copy on another server for read-only purposes. The read-only database is on SQL Server 2008. Once the database is on the new server we'd like to optimize it for read-only use. One problem is that there are large amounts of allocated space for some of the tables that are unuse...

How to duplicate a SQL Server 2000 table programatically using .NET 2.0?

I want to backup a table saving the copy in the same database with another name. I want to do it programatically using .NET 2.0 (preferably C#). Someone can point me what should I do? ...

SQL Server trigger on replication

I need to create a SQL Server database that will recieve updates by some replication mechanism from another database. I need to write insert, update and delete triggers that will execute when this replilcation occurs. I have experience with triggers but not with replication. Should I use Transactional or Merge replication, or does it m...

Publicly available SQL Server replication Publisher

I'm trying out SQL Server 2008 Express Edition and I'm interested in trying the replication features. Is there a publicly available database to which I could set up a replication subscription? ...

PHP mssql_connect works in Command Line but not Apache

Just wanted to share an issue I was experiencing trying to connect to a remote MSSQL Server with mssql_connect(), from a ubuntu box. With identical php.ini files and correct permissions the connect would be established when I ran the connection script through the command line, but not in the browser. ...