|
Hi,
Can you set a column to store data right aligned? (the reason i want to know this is because all our values are set to char() datatype in SQL database. This will mean that the left out characters / the character that are short will be filled in with blank spaces. Having the value right aligned will mean that the spaces will be put in front of the value and not at the back and that is what i am looking for (if this is possible).)
OR
is there a way to select the values from the database as right aligned (i will be using the REPLACE(TheRecordFromTheTable, ' ','') , this will help to remove the added spaces from the back due to char() datatype.)
Thank you in advance...
"Many of life's failures are people who did not realize how close they were to success when they gave up." Thomas A. Edison
|
|
|
|
|
hi
plz clarify your question...
Regards
Joe
|
|
|
|
|
Support123 wrote: is there a way to select the values from the database as right aligned
May I know what is your objective in doing so?
|
|
|
|
|
Is this what you are trying
declare @a char(20)<br />
set @a = 'testing'<br />
select right(space(20) + rtrim(@a), 20)
1. Removing spaces at end
2. Adding at the begining
3. Ignoring extra spaces from begining
Regards
KP
|
|
|
|
|
Support123 wrote: Can you set a column to store data right aligned? (the reason i want to know this is because all our values are set to char() datatype in SQL database. This will mean that the left out characters / the character that are short will be filled in with blank spaces. Having the value right aligned will mean that the spaces will be put in front of the value and not at the back and that is what i am looking for (if this is possible).)
OR
is there a way to select the values from the database as right aligned (i will be using the REPLACE(TheRecordFromTheTable, ' ','') , this will help to remove the added spaces from the back due to char() datatype.)
Is there a particular reason why you are storing numbers as strings? Wouldn't storing numbers as binary fields be more efficient?
|
|
|
|
|
Thank all of you...
BUT never mind... i found a way around my problem... sorry for stating my question so unclear. I wasn't even sure what i needed.
What i wanted to do is add the spaces in front of some of the Values in the database. This is then easier when i have to populate the flatfile using ssis package. (The reason why i store the numbers as CHAR() is just a staging table. Easier to get the fixed length right )
Thank you all once again for the effort.
"Many of life's failures are people who did not realize how close they were to success when they gave up." Thomas A. Edison
|
|
|
|
|
i have applied the following query but in output one record appears repeatedly, can u check whether there is any error in query santax, perhaps i have used 'AND' 2 TIMES
SELECT crime_mgmt.cr_location,crime_mgmt.cr_date,offensive_issue.c_desc FROM crime_mgmt,offensive_issue WHERE crime_mgmt.fir_num = offensive_issue.fir_num AND crime_mgmt.cr_date BETWEEN '" + crimewithdate.text.ToString() + "' AND '" + crimewithdate.text1.ToString() + "'ORDER BY crime_mgmt.cr_date ASC
|
|
|
|
|
SELECT crime_mgmt.cr_location,crime_mgmt.cr_date,offensive_issue.c_desc
FROM crime_mgmt inner join offensive_issue on crime_mgmt.fir_num = offensive_issue.fir_num
WHERE crime_mgmt.cr_date BETWEEN '" + crimewithdate.text.ToString() + "' AND '" + crimewithdate.text1.ToString() + "'ORDER BY crime_mgmt.cr_date ASC
and dont forget to enclose it properly as far as thequotes are concerned. you're better off chking the value of the actual query formed while debugging.
Rocky
You can't climb up a ladder with your hands in your pockets.
|
|
|
|
|
Could be possible of your date format. just try to check your input date and date store in table.
Devjit Das.
|
|
|
|
|
mavii wrote: have applied the following query but in output one record appears repeatedly
This can happen when there are multiple rows for same "fir_num"
can you provide table structure with sample data.
Regards
KP
|
|
|
|
|
Interesting, and quite disappointing, that no one picked you up on the fact that your code is susceptable to a SQL Injection attack.
Please learn about SQL Injection Attacks and tips on how to prevent them[^] - most likely by following that advice you will solve other problems as well.
|
|
|
|
|
Colin Angus Mackay wrote: Interesting, and quite disappointing, that no one picked you up on the fact that your code is susceptable to a SQL Injection attack
I'm sorry Colin. I didn't even read his post until after I read your response. Mind you, it's interesting that the system he was working on had something to do with crime management (I'm inferring this from the table name). I would have thought that he'd want to make things as secure as possible beforehand.
|
|
|
|
|
Pete O`Hanlon wrote: I would have thought that he'd want to make things as secure as possible beforehand.
Indeed. Unless, of course, he's in league with certain elements.....
|
|
|
|
|
Hi,
i'm searching for a stored procedure (or other way) to create scripts from objects in a database, given the object as parameter.
Reason i do this is :
I want to create a script of all objects modfied after a certain date. Those i can retrieve using
select * from sys.all_objects where /*name like 'tbl_%' and*/ modify_date > '2007-10-29'
but now i want to create automatically a script of those modified objects.
Thx
Kurt
|
|
|
|
|
hi
You can use EnterPriseManager to create the script of objects.
Then why r u searching for Stored Procedures.
Reagrds
Joe
|
|
|
|
|
hi,
i want it to generate automatically, not using the enterprise manager or studio..
a select from systemobjects and use those to generate all new or modified tables, triggers and stored procs... in one action, without selecting them yourself.
greetz
kurt
|
|
|
|
|
hi genius people i need help again.. and tnx again in advance!!!
i just want to get the execution time of every query made or views or stored procedure executed.. just like in the query analyzer when you execute a command or any query.. i just want it displayed while on
run time or after the run time
is it possible?or am i just too newbie for this..
|
|
|
|
|
Hi all
How to convert FLOAT to INT in SQL Server2000
When i use cast or convert function get this error
Server: Msg 232, Level 16, State 3, Line 1
Arithmetic overflow error for type int, value = 2400000000.000000.
The statement has been terminated.
Thank
|
|
|
|
|
Max value for INT data type is 2147483647
Use BIGINT as the value you are trying to convert is more than the max value of INT
Regards
KP
|
|
|
|
|
It is clear, but if i'm still needed to convert bigest value to more easy, is an way exists???
|
|
|
|
|
In SQL there are INT & BINT data types
currently you are using INT
instead user BIGINT
Regards
KP
|
|
|
|
|
hai ,
i got count(Empid) from one viewtbl and count(dept) from another table in one storedprocedure,
i want the percentage of count(Empid) and count(dept)
Thanks in advance
Thanks
Subbu.
|
|
|
|
|
How is this different than the question you asked just several hours earlier, that Pete already answered? Unless this is an entirely different question, you'd probably be better off continuing the thread you already started.
Sorry if it's obvious to everyone else...
David
---------
Empirical studies indicate that 20% of the people drink 80% of the beer. With C++ developers, the rule is that 80% of the developers understand at most 20% of the language. It is not the same 20% for different people, so don't count on them to understand each other's code.
http://yosefk.com/c++fqa/picture.html#fqa-6.6
---------
|
|
|
|
|
I'm starting a new project next year (business application)
I will be the only one working on it from a start,
but my SQL knowledge is limited (not the SQL syntax, but the database design)
Until now I've sorted my problems on the way, but that's not a long term solution that I'm looking for,
so can anyone point me to some good articles (or books in e-book format as I live in a country with limited book availability)
Thanks in advance
|
|
|
|
|
progress-database-design-guide/[^]
en.wikipedia.org/wiki/Database_design
www.databasedesign-resource.com
well u should consider getting urself acquianted with basic db design principles and normalization (uptp 3NF atleast).
wikipedia can also be helpful for u and Google offcourse is also there to help u out.
Hope that helps u
best of luck
Rocky
You can't climb up a ladder with your hands in your pockets.
|
|
|
|