Click here to Skip to main content
15,899,474 members
Home / Discussions / Database
   

Database

 
GeneralRe: Select statement: ordering by column name. Pin
Septimus Hedgehog24-Jun-13 1:55
Septimus Hedgehog24-Jun-13 1:55 
AnswerRe: Select statement: ordering by column name. Pin
GuyThiebaut24-Jun-13 2:10
professionalGuyThiebaut24-Jun-13 2:10 
GeneralRe: Select statement: ordering by column name. Pin
Tim Carmichael24-Jun-13 4:23
Tim Carmichael24-Jun-13 4:23 
GeneralRe: Select statement: ordering by column name. Pin
GuyThiebaut24-Jun-13 5:03
professionalGuyThiebaut24-Jun-13 5:03 
AnswerRe: Select statement: ordering by column name. Pin
David Mujica24-Jun-13 2:37
David Mujica24-Jun-13 2:37 
AnswerRe: Select statement: ordering by column name. Pin
Ralph D. Wilson II10-Jul-13 7:40
Ralph D. Wilson II10-Jul-13 7:40 
GeneralRe: Select statement: ordering by column name. Pin
Septimus Hedgehog10-Jul-13 20:11
Septimus Hedgehog10-Jul-13 20:11 
GeneralRe: Select statement: ordering by column name. Pin
Ralph D. Wilson II11-Jul-13 7:15
Ralph D. Wilson II11-Jul-13 7:15 
Th following could be implemented as a Sotred Procedure or simply executed as is in a query:

SQL
USE {enter your desired database name here};

DECLARE     @NameOfTable     VarChar(128);
SET     @NameOfTable = '{enter your desired table name here}';

DECLARE @SQLStatement VarChar(8000);

SET @SQLStatement =  'SELECT ''' + @NameOfTable + ''' AS TableName';

PRINT @SQLStatement;

EXEC(@SQLStatement);

WITH TableColumns_CTE
AS
(
    SELECT   T.name     AS  TableName
            ,C.name     AS  ColumnName
            ,ROW_NUMBER() OVER (PARTITION BY T.name ORDER BY T.name, C.name) Seq
    FROM    sys.tables T
    INNER JOIN sys.columns C
       ON   T.object_id = C.object_id
      AND   T.name = @NameOfTable
)

SELECT   @SQLStatement = @SQLStatement + ', ' + ColumnName
FROM    TableColumns_CTE;

SELECT   @SQLStatement = @SQLStatement + ' FROM ' + @NameOfTable + ';';

PRINT @SQLStatement;

EXEC(@SQLStatement);

GeneralRe: Select statement: ordering by column name. Pin
Septimus Hedgehog11-Jul-13 10:27
Septimus Hedgehog11-Jul-13 10:27 
GeneralRe: Select statement: ordering by column name. Pin
Ralph D. Wilson II31-Jul-13 5:59
Ralph D. Wilson II31-Jul-13 5:59 
GeneralRe: Select statement: ordering by column name. Pin
Septimus Hedgehog31-Jul-13 7:46
Septimus Hedgehog31-Jul-13 7:46 
QuestionSQL Database Security Pin
Zeyad Jalil22-Jun-13 0:04
professionalZeyad Jalil22-Jun-13 0:04 
AnswerRe: SQL Database Security Pin
Eddy Vluggen22-Jun-13 7:24
professionalEddy Vluggen22-Jun-13 7:24 
AnswerRe: SQL Database Security Pin
Mycroft Holmes22-Jun-13 13:40
professionalMycroft Holmes22-Jun-13 13:40 
Generalmysql or postgresql for Ubuntu + Java trading system? Pin
crunchor21-Jun-13 20:41
crunchor21-Jun-13 20:41 
GeneralRe: mysql or postgresql for Ubuntu + Java trading system? Pin
Rutvik Dave21-Jun-13 21:20
professionalRutvik Dave21-Jun-13 21:20 
GeneralRe: mysql or postgresql for Ubuntu + Java trading system? Pin
Matthew Faithfull21-Jun-13 21:51
Matthew Faithfull21-Jun-13 21:51 
GeneralRe: mysql or postgresql for Ubuntu + Java trading system? Pin
crunchor21-Jun-13 23:56
crunchor21-Jun-13 23:56 
GeneralRe: mysql or postgresql for Ubuntu + Java trading system? Pin
Bernhard Hiller23-Jun-13 21:25
Bernhard Hiller23-Jun-13 21:25 
QuestionGenerating Custom XML from multiple rows in SQL server Pin
ONeil Tomlinson19-Jun-13 5:10
ONeil Tomlinson19-Jun-13 5:10 
AnswerRe: Generating Custom XML from multiple rows in SQL server Pin
Richard MacCutchan19-Jun-13 7:00
mveRichard MacCutchan19-Jun-13 7:00 
AnswerRe: Generating Custom XML from multiple rows in SQL server Pin
RedDk23-Jun-13 9:21
RedDk23-Jun-13 9:21 
QuestionHow to permanently solve (blocked because of many connection0 error? Pin
Jassim Rahma18-Jun-13 2:25
Jassim Rahma18-Jun-13 2:25 
AnswerRe: How to permanently solve (blocked because of many connection0 error? Pin
jschell18-Jun-13 8:40
jschell18-Jun-13 8:40 
AnswerRe: How to permanently solve (blocked because of many connection0 error? Pin
Bernhard Hiller19-Jun-13 21:13
Bernhard Hiller19-Jun-13 21:13 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.