sql-server

SQL Server: preserve calculated fields with a SELECT INTO

Hello, My company performed a data migration recently (in a SQL Server 2005 database) and we noticed that some tables created with SELECT INTO didn't maintained the calculated fields of the original tables, but instead SQL Server created regular fields with the type returned by the original calculation. For example, suppose that you hav...

Can you limit the number of rows in a (database) table?

We have a database (SQL Server 2005) which we would like to get under source control. As part of that we are going to have a version table to store the current version number of the database. Is there a way to limit that table to only holding one row? Or is storing the version number in a table a bad idea? Ended up using this appro...

Using SQL Server back end for Subversioning Repositories

Has anyone attempted to use SQL Server Database as a Subversion file system back end? So that all Subversion Repositories would be stored in a SQL Database instead of a flat file system? Make for easier backups and reporting? ...

SQL Server GUI For Linux

Anybody know of a GUI for querying / managing Microsoft SQL Server >= 2005 from Linux. So far I've only found Razor SQL http://www.razorsql.com/download_linux.html ...

Synchronization of sql server 2000 and postgresql 8.3

the scenario: Two databases(each has a database named, for example testdb): MS Sql Server 2000 Postgresql 8.3 I need to synchronize these two testdbs, actually the direction is from SqlServer to Postgresql. The structure of testdb on SqlServer may change occasionally. I only need tables and data of testdb synchronized, exclude ind...

Missing drive when attaching database in SQL Management Studio 2005

I'm trying to attach an external mdf file to my SQLEXPRESS instance from within the SQL Management Studio 2005. However, I'm unable to see the drive that the database file resides in under the directory browser within the "Locate Database Files" prompt. Is there anything that is preventing the Management Studio or the SQL instance from ...

Hacky Sql Compact Workaround

So, I'm trying to use ADO.NET to stream a file data stored in an image column in a SQL Compact database. To do this, I wrote a DataReaderStream class that takes a data reader, opened for sequential access, and represents it as a stream, redirecting calls to Read(...) on the stream to IDataReader.GetBytes(...). One "weird" aspect of IDa...

Is it possible to create databases programmatically using DBX?

Looks like the TSQLConnection only connects to existing databases, and I could not find another component that allows me to send commands to the database server. I'm using Delphi 2009 with Firebird and MSSQL. One idea that came was to connect to a system database (master or tempdb in MSSQL for example) and then send create commands to ...

Do I have to close the SQL Connection manually if I use Linq?

Traditionally, when we use SQL string to done some work, we have to close the sql connection before the page being closed, I was wondering if I use Linq to do the data operations do I still need to close the connection manually? ...

How to find where all of the space in a SQLServer database is being used

We have a SQL server database which, according to Microsoft SQL Server Management Studio has just 119Mb out of 6436Mb available. Yet the command: EXEC sp_msforeachtable 'sp_spaceused ''?''' reveals a total reserved space that is less than 2Gb How can we find out where the rest of the space is being used? ...

Difference between GO and BEGIN...END

Is there a difference between "GO" and "BEGIN...END" in SQL Scripts/Stored Procedures? More specifically, does BEGIN...END specify batches just as GO does? ...

How do I create a DSN for ODBC in Linux?

I am digging around in a Linux application that supposedly uses DSNs to connet to SQL Server. The connection stopped working and I can't find the credentials that are being used (all I know is the DSN's name). I am familiar with DSNs in Windows, but how are they created and where are they stored in Linux? ...

How can I handle non-ASCII characters when retrieving data from SQL Server using Perl?

I have a Perl script running on UNIX that uses DBI to connect to and retrieve data from a SQL Server database. The script looks like the following: $dbh = DBI->connect("dbi:Sybase:server=$connect;charset=UTF-8", $login, $password) or die("Couldn't connect to $connect as $login/$password: $DBI::errstr"); $sql = "use mydb"; $sth = $dbh-...

Which is faster? Multiple DELETE statements or a single DELETE Statement using "IN ('x', ''y')"

Just wondering which is faster: DELETE FROM table_name WHERE X='1' DELETE FROM table_name WHERE X='2' DELETE FROM table_name WHERE X='3' or DELETE FROM table_name WHERE X IN ('1', '2', '3') Any ideas, hints, or references where to read? Thank you all! ...

Is there anyway to speed up SQL Server Management Objects traversal of a existing database?

I'm currently using SMO and C# to traverse databases to create a tree of settings representing various aspects of the two databases, then comparing these trees to see where and how they are different. The problem is, for 2 reasonably sized database, it takes almost 10mins to crawl them locally and collect table/column/stored procedure i...

Foreign Keys

Hi , Can somebody please, let me know the best way to delete a table referenced by a foreign keys. Thanks, Chris ...

How to catch a SQL server cracker?

Quick synopsis: The guys on my team have been working on a production database (sql server 2005). We've added various things such as constraints, added triggers, etc. Now we've found that someone or something has been rolling back our changes at various times. Problem is we all share a common admin login. (dumb, yeah I know, we're fixi...

How to set up access to MSSQL 2005 Database Mail?

I've just setup Database mail within MSSQL 2005. I have been able to send email from an administrator account on the server and through a SQL Server Agent job. But, I unable to send email when I tried to send email via a login that just has access to a database for our web application. What is the best way to set up access to Database M...

Using Full-Text Search in SQL Server 2008 across multiple tables, columns

I need to search across multiple columns from two tables in my database using Full-Text Search. The two tables in question have the relevant columns full-text indexed. The reason I'm opting for Full-text search: 1. To be able to search accented words easily (cafè) 2. To be able to rank according to word proximity, etc. 3. "Did you mean...

How do you like your primary keys?

In a fairly animated discussion in my team I was made to think what most people like as primary keys. We had the following groups- Int/ BigInt which autoincrement are good enough primary keys. There should be at least 3 columns that make up the primary key. Id, GUID and human readable row identifiers all should be treated differently. ...