Tag Info

New answers tagged

0

Linked servers aren't usually a good idea from a security perspective. See distribution statistics section here I think SSIS would provide a better way of doing this.


1

I use something like this to create dynamic pivots with a dynamic number of columns. Perhaps it will help you with your solution. It's a single statement to avoid looping or cursors. declare @strSQL as varchar(max) declare @columns as varchar(max) declare @columns1 as varchar(max) set @columns = (select stuff ((select ',cast(' + quotename(columnname) + ' ...


1

Adding an example to Michael's answer. The problem with the PIVOT is two fold. 1st, it wants to aggregate. You can get around this by defining your dataset to be distinct and using MAX or MIN functions. But your example above makes that impossible, due to a user being able to have multiple answer sets for a given question. You would end up with only one ...


3

If you can use #temp tables instead of table variables, this becomes dead easy. CREATE TABLE #Table1 ( Table1ID Int Primary Key, ColumnName varchar(max) ); INSERT INTO #Table1(Table1ID,ColumnName) VALUES(1000,'A'),(2000,'B'); CREATE TABLE #Table2 ( Table2ID Int Identity Primary Key, Table1ID Int, FieldData varchar(max) ); INSERT INTO ...


3

It will be available in 9.5. Here is actual git commit https://github.com/postgres/postgres/commit/08309aaf74ee879699165ec8a2d53e56f2d2e947 Discussion on pg hackers http://postgresql.nabble.com/CREATE-IF-NOT-EXISTS-INDEX-td5821173.html



Top 50 recent answers are included