97
votes
10answers
47k views

Simulating group_concat MySQL function in Microsoft SQL Server 2005?

I'm trying to migrate a MySQL-based app over to Microsoft SQL Server 2005 (not by choice, but that's life). In the original app, we used almost entirely ANSI-SQL compliant statements, with one ...
77
votes
11answers
89k views

T-SQL: Opposite to string concatenation - how to split string into multiple records [duplicate]

Possible Duplicate: Split string in SQL I have seen a couple of questions related to string concatenation in SQL. I wonder how would you approach the opposite problem: splitting coma ...
132
votes
15answers
233k views

Split string in SQL

Using SQL Server 2005, how do I split a string so I can access item x? For example, take the string "Hello John Smith". How can I split the string by a space and access the item at index 1 which ...
410
votes
17answers
585k views

How to SELECT * INTO [temp table] FROM [stored procedure]

How do I do a SELECT * INTO [temp table] FROM [stored procedure]? Not FROM [Table] and without defining [temp table]? Select all data from BusinessLine into tmpBusLine works fine. select * into ...
46
votes
7answers
18k views

Parameter Sniffing (or Spoofing) in SQL Server

A while ago I had a query that I ran quite a lot for one of my users. It was still being evolved and tweaked but eventually it stablised and ran quite quickly, so we created a stored procedure from ...
144
votes
11answers
87k views

varchar vs nvarchar performance

I'm working on a database for a small web app at my school using SQL Server 2005. I see a couple of schools of thought on the issue of varchar vs nvarchar: Use varchar unless you deal with a lot of ...
27
votes
10answers
60k views

How to return multiple values in one column (T-SQL)?

I have [UserAliases] (UserId, Alias) table with multiple Aliases per user. I need to query it and return all aliases for a given user, the trick is to return them all in one column. Example: ...
12
votes
3answers
14k views

Does T-SQL have an aggregate function to concatenate strings? [duplicate]

Possible Duplicates: Implode type function in SQL Server 2000? Concatenate row values T-SQL I have a view which I'm querying that looks like this: BuildingName PollNumber ...
7
votes
5answers
7k views

What is the best way to create and populate a numbers table?

I've seen many different ways to create and populate a numbers table. However, what is the best way to create and populate one? With "best" being defined from most to least important: Table ...
7
votes
2answers
5k views

best way to convert and validate a date string

I have a single char(8) variable formatted as ddmmyyyy in a stored procedure (quality and validity of this value is unknown and beyond my control). What is the best most efficient way to move the ...
74
votes
7answers
126k views

SQL update query using joins

I have to update a field with a value which is returned by a join of 3 tables. Example: select im.itemid ,im.sku as iSku ,gm.SKU as GSKU ,mm.ManufacturerId as ManuId ...
14
votes
5answers
9k views

Do I really need to use “SET XACT_ABORT ON”?

if you are careful and use TRY-CATCH around everything, and rollback on errors do you really need to use: SET XACT_ABORT ON In other words, is there any error that TRY-CATCH will miss that SET ...
5
votes
4answers
915 views

Concatenate values based on ID

I Have a table called Results and the data looks like: Response_ID Label 12147 It was not clear 12458 Did not Undersstand 12458 Was not resolved 12458 Did not ...
18
votes
4answers
34k views

Simulation of CONNECT BY PRIOR of ORACLE in SQL SERVER

I would like to get the functionality of CONNECT BY PRIOR of ORACLE in SQL SERVER 2000/2005/2008? Please help me
87
votes
8answers
23k views

How do I create unique constraint that also allows nulls in sql server

The question is quite simple, as the title. Added a column to table I want a unique constraint , the column will insert guids, but to allow for existing data before column was added I need to allow ...

1 2 3 4 5 68
15 30 50 per page