sql-server

SQL Server Regular expressions in T-SQL

Is there any regular expression library written in T-SQL (no CLR, no extended sp, pure t-sql) for SQL Server? (should work with shared hosting) Edit: thanks I know about PATINDEX, LIKE, xp_ sps and CLR solutions I also know it is not the best place for regex, the question is theoretical:) reduced functionality is also accepted ...

In SQL Server, how do you concatenate many rows into a single text string?

Say you have a table Names that has three rows: Peter Paul Mary Is there an easy way to turn this into a single string of "Peter, Paul, Mary"? ...

Where to find a good reference when choosing a database?

I and two others are working on a project at the university. In the project we are making a prototype of a MMORPG. We have decided to use PostgreSQL as our database. The other databases we considered were MS SQL-server and MySQL. Does somebody have a good reference which will justify our choice? (preferably written during the last yea...

What is a "pseudocolumn"? Accidently coded "SELECT $FOO.." and got the error "Invalid pseudocolumn "$FOO".

I can't find any documentation for them. Is it something I should know? Edit: this is a MS SQL Server specific question. ...

Is there a way I can retrieve sa password in sql server 2005

I just forgot the password. Can anyone help me how to get back the password. ...

Date ranges in T/SQL

For a current project I am working I need to return an aggregate report based on date ranges. I have 3 types of reports, yearly, monthly and daily. To assist in returning this report I need a function that will return all of the sub-ranges of datetimes, within a big range. So for example if I as for all the daily ranges between '2006...

What's the best way to use SqlBulkCopy to fill a really large table?

Nightly, I need to fill a SQL Server 2005 table from an ODBC source with over 8 million records. Currently I am using an insert statement from linked server with syntax select similar to this: Insert Into SQLStagingTable from Select * from OpenQuery(ODBCSource, 'Select * from SourceTable') This is really inefficient and takes hours to...

Select specific rows with SQL Server XML column type

I'm trying to select data from a table defined similar to the following : Column | Data Type ------------------------- Id | Int DataType | Int LoggedData | XML but I only want to select those rows with a specific DataType value, and that contain a string (or evaluates a piece of XPath) in the LoggedData colum...

Data Cut off when exporting to excel in SQL Reporting Services 2005.

I am having huge lines data which could accomdate in Textbox. While I am exporting to excel the wrapping up of data occurs and the data is being cut off. When i manually change the textbox height i can see the full data but i need the full data to be displayed in the first time itself. ...

Best way to search in a varchar column in sql server

Hi, What would you recommend to search a sql server table (varchar(max) column) for a term? Let's say, like in ebay, if you search for "wii brand new", you get results like "Brand New Nintendo Wii Fit Game + Balance Board Bundle", "Wii Fit (Wii) BRAND NEW WII FIT GAME + BALANCE BOARD". I think it basically searches every word and retur...

Select products where the category belongs to any category in the hierarchy

I have a products table that contains a FK for a category, the Categories table is created in a way that each category can have a parent category, example: Computers Processors Intel Pentium Core 2 Duo AMD Athlon I need to make a select query that if the selected category is Proc...

How do I assign weights to different columns in a full text search?

In my full text search query, I want to assign particular columns a higher weightage. Consider this query: SELECT Key_Table.RANK, FT_Table.* FROM Restaurants AS FT_Table INNER JOIN FREETEXTTABLE(Restaurants, *, 'chilly chicken') AS Key_Table ON FT_Table.RestaurantID = Key_Table.[KEY] ORDER BY Key_Table.RANK DESC Now, I want the Name c...

How can I get the size of the Transaction Log in SQL 2005 programmatically?

We're working with a fixed transaction log size on our databases, and I'd like to put together an application to monitor the log sizes so we can see when things are getting too tight and we need to grow the fixed trn log. Is there any TSQL command that I can run which will tell me the current size of the transaction log, and the fixed ...

SQL Server unique set of columns without using a constraint - getting bit by the 900 byte limit

Hello, I have a table which contains 3 nvarchar(255) columns and a combination of these 3 columns must be unique. Normally I would create a Unique constraint, but in this case, I am hitting the 900 byte limit. Since I have to support SQL Server 2000, I can not use Include columns to get around this situation. Thanks! ...

PIVOT in sql 2005

I need to pivot one column (Numbers column). example need this data: a 1 a 2 b 3 b 4 c 5 d 6 d 7 d 8 d 9 e 10 e 11 e 12 e 13 e 14 Look like this a 1 2 b 3 4 c 5 d 6 7 8 9 e 10 11 12 13 14 any help would be greatly appreciated... ...

Visual Studio 2008 crashes horribly

Hi all, This has happened to me 3 times now, and I am wondering if anyone is having the same problem. I am running Visual Studio 2008 SP1, and hitting SQL Server 2005 developer edition. For testing, I use the Server Explorer to browse a database I have already created. For testing I will insert data by hand (right click table -> show...

How much compatibility do the DB engines have at the SQL level?

Let's say I wanted to have an application that could easily switch the DB at the back-end. I'm mostly thinking of SQL Server as the primary back-end, but with the flexibility to go another DB engine. Firebird and PostGreSQL seem to have (from my brief wikipedia excursion) the most in common w/ SQL Server (plus they are free). How simil...

Attempted SQL injection attack - what are they trying to do?

I have a public facing website that has been receiving a number of SQL injection attacks over the last few weeks. I exclusively use parameterised stored procedures so I believe that there has been no successful attacks, but a recent log showed an interesting technique: Line breaks added for clarity http://www.mydummysite.uk/mypage.as...

How do I prevent inserting new records into tables while using Linq and SQL?

When creating a new object that is mapped to one of my SQL Server tables, LINQ inserts a new record into the table when I call SubmitChanges. I want to prevent this, but still need my new object. I know about the custom methods, but is there anyway to disable this behaviour so that it just updates existing records and never inserts new...

What's the difference between SQLNCLI and .NET Framework Data Provider for SQL Server

I have an application which uses a UDL file where the connection string specifies "Provider=SQLNCLI.1" which doesn't work on a specific machine because sqlncli.dll is not installed. Another .Net app however, where the connection string is in app.config and does not specifically show the provider does worrk. The "Change Data Source" dial...