Can I use a column number instead of a column name in which the query selection condition in SQL Server 2005?

we can use the column number instead of the column name in which the query selection condition in SQL Server 2005 is such that even if the column name takes so long.

early.

+3
source share
9 answers

no, you cannot directly, just drag the column name you want from the explorer object into your query ... you don't need to enter it

Press F8, Object Browser will open. Go to DatabaseName / TableName / Columns. Click on the column folder and drag the column folder into the code window. Once released, you will see that all column names are in the code window.

( )

SQL Information_schema.columns _ . 5, _ 5, . , ,

+5

. , , . , , .

SQL; , , .

+4

, , :

SELECT  *
FROM    (
        SELECT  Supercalifragilisticexpialidociousness AS s
        FROM    mytable
        ) q
WHERE   s = 1

SQL Server , , .

+3

.

, SELECT / WHERE...

+3

, . , . , , , ( , 128 MS SQL)

+2

select * from table_name somecolumn = 5 insted,

, , , . , SQL-.

declare @colname varchar(128)
declare @sql varchar(max)
set @colname = 'Server'
set @sql = 'select * from Jobs where '+@colname+'='+'''S02AAPEXP01'''
exec (@sql)

, , !!!

+2

, WHERE. ORDER BY. , ORDER BY

SELECT ServerCode, Count(*) as Databases 
FROM DatabaseList 
GROUP BY ServerCode 
ORDER BY 2 DESC

SELECT EventCode, EndTime, Convert(Varchar(50),TextData) as QueryName, CPU, READS
FROM TraceData
ORDER BY 3

, proc? .

+1

, SQL intellisense, , RedGate .

SqL Prompt

SQL 2008, , Intellisense.

0

, , , / SQL Server.

1 - Query Analyzer ( ). Alt - F1. , . , , Ctrl - C, Ctrl - V, . , .

2 - Script /SELECT To/Clipboard. , .

0
source

Source: https://habr.com/ru/post/1711584/


All Articles