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.
| 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. |
 |
|
|
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] |
 |
|
|
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 ........etcfrom Table |
 |
|
|
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. |
 |
|
|
BJM RAO
Starting Member
20 Posts |
Posted - 2009-03-15 : 06:32:14
|
| Thanks Rohit |
 |
|
|
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 csetks |
 |
|
|
rohitkumar
Constraint Violating Yak Guru
472 Posts |
Posted - 2009-03-16 : 13:16:42
|
| dude thats just an example |
 |
|
|
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. |
 |
|
|
|
|
|