March 24, 2014 at 7:42 am
Drop Table #TEMP2
Create Table #TEMP2(ABCD1234 varchar(50))
I want to select column name from #TEMP2 table. When displaying the column name , it should show ABCD alone(1234 no need to show). Pls help me.
March 24, 2014 at 7:46 am
Do you mean something like this?
select ABCD1234 as ABCD from #TEMP2
Adi
--------------------------------------------------------------
To know how to ask questions and increase the chances of getting asnwers:
http://www.sqlservercentral.com/articles/Best+Practices/61537/
For better answers on performance questions, click on the following...
http://www.sqlservercentral.com/articles/SQLServerCentral/66909/
March 24, 2014 at 7:52 am
i want output like below:
select name from sys.columns where object_ID=3 /* Query something like this */
Output :
ABCD
March 24, 2014 at 8:00 am
Why would you need something like that? In any case here is one way of doing it, can you pleas explain why do you need it?
create table t (abcd1234 int)
go
select name, substring(name, 1, patindex('%[0-9]%',name)-1) from sys.columns where object_id = object_id('t')
go
--cleanup
drop table t
Adi
--------------------------------------------------------------
To know how to ask questions and increase the chances of getting asnwers:
http://www.sqlservercentral.com/articles/Best+Practices/61537/
For better answers on performance questions, click on the following...
http://www.sqlservercentral.com/articles/SQLServerCentral/66909/
March 24, 2014 at 8:09 am
balu.arunkumar (3/24/2014)
i want output like below:select name from sys.columns where object_ID=3 /* Query something like this */
Output :
ABCD
That's something completely different from your first question.
If you named the column ABCD1234, that's how it is stored in the system metadata.
Need an answer? No, you need a question
My blog at https://sqlkover.com.
MCSE Business Intelligence - Microsoft Data Platform MVP
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply