Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 All UPPER CASE

Author  Topic 

BJM RAO
Starting Member

20 Posts

Posted - 2009-03-13 : 10:06:28
Dear ...
I have a table with 10 columns (say so ..) with data entered in both the cases (lower and upper) but i wish to obtain the data in upper case for the whole table in one go of select statement.

Select Upper(*) From TableName doesnt work

tks

rohitkumar
Constraint Violating Yak Guru

472 Posts

Posted - 2009-03-13 : 10:13:33
use dynamic sql to construct your SELECT statement and execute it.
Go to Top of Page

rohitkumar
Constraint Violating Yak Guru

472 Posts

Posted - 2009-03-13 : 10:51:53
[CODE]
DECLARE @t TABLE(
col VARCHAR(250)
)

DECLARE @TABLE_NAME VARCHAR(100)

DECLARE @MyQuery VARCHAR(MAX)

SET @TABLE_NAME = 'DimProduct'

INSERT INTO @t
SELECT 'UPPER(' + column_name + ') AS ' + column_name
FROM information_schema.columns
WHERE table_name = @TABLE_NAME

SELECT @MyQuery = 'SELECT ' + Left(mycols,Len(mycols) - 1) + ' FROM ' + @TABLE_NAME
FROM (SELECT (SELECT col + ', ' AS [text()]
FROM @t
ORDER BY col DESC
FOR XML PATH('')) AS mycols) a

--print @myquery
EXECUTE( @MYQUERY)
[/CODE]
Go to Top of Page

darkdusky
Aged Yak Warrior

591 Posts

Posted - 2009-03-13 : 11:31:52
Or else just
Select UPPER(a)as A,Upper(b)as B,Upper(c)as C ........etc
from Table
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-03-13 : 14:01:36
why should you be concerned about doing this in sql? i think this is a formatting issue which you can do easily at your front end.
Go to Top of Page

BJM RAO
Starting Member

20 Posts

Posted - 2009-03-15 : 06:32:14
Thanks Rohit
Go to Top of Page

BJM RAO
Starting Member

20 Posts

Posted - 2009-03-16 : 13:04:57
Rohit
The dynamic query is ok, but at the end i couldnt find the table (DimProduct)with columns in all upper case which was the aim ...

pse cross check inorder to obtain the result of the table in all upper cse

tks
Go to Top of Page

rohitkumar
Constraint Violating Yak Guru

472 Posts

Posted - 2009-03-16 : 13:16:42
dude thats just an example
Go to Top of Page

BJM RAO
Starting Member

20 Posts

Posted - 2009-03-16 : 13:20:29
true but how to obtain the result from the provided query fullfilling the condition.
Go to Top of Page
   

- Advertisement -