|
Im returning ratios with rounded off to 3 decimals places, but when the rounding off function doesnt get rid of of the trailing 10 zeroes. How do I get rid of the trailing zeros because it shows in SQL reports. I have tried TRUNCNUM, ROUND, TRUNC. I just cant seem to get rid of those zeroes. Help would much be appreciated.
|
|
|
|
|
Hi!
Try FormatNumber function.... see the example below. If you are not going to define 0 in FormatNumber statement, it will show decimal places.
NewNumber = FormatNumber(OldNumber,0)
|
|
|
|
|
thanks bro, but i sorted it out now. first casted it to a 'real' number then used the 'round' function. and it worked. all trailing zeroes are now removed
|
|
|
|
|
hi all
i have a colunm in my DB ( nvarchar (50)) i use it to store customer's e-mail but this column takes only the first 20 Cahrs from the user's input
i tried to make it 100 in length but nothing work
plz tell me wht to do
thank u
abdelhameed81
|
|
|
|
|
You have a problem in your client-side application. Either the text is being truncated to 20 characters somewhere in that application, or you are using a SqlParameter object (or other similar object appropriate for your database and development language/platform) with size 20.
|
|
|
|
|
What is SQL injection, and how it occurs,
How can we rectify the SQL injection
-
|
|
|
|
|
|
Difference between DELETE, TRUNCATE, DROP
-
|
|
|
|
|
DELETE removes rows from a table and ensures that referential integrity is maintained, triggers are run and so on.
TRUNCATE just removes the rows and to hell with the consequences
DROP removes an object (like a table, stored procedure, function, view, etc.) from the database
|
|
|
|
|
I'd add to Colin's post that you can recover from DELETE with a rollback, while TRUNCATE and DROP do not provide any mechanism to recover.
Chris Meech
I am Canadian. [heard in a local bar]
Nobody likes jerks. [espeir]
The zen of the soapbox is hard to attain...[Jörgen Sigvardsson]
I wish I could remember what it was like to only have a short term memory.[David Kentley]
|
|
|
|
|
I am using xml(.) datatype in sql ser 2005
I want to get the value as string without using dataset
because the data is very huge, if i took by dataset the end values were truncated
i want to get the value directly inside a stored procedure and to pass the value as an input to openXML in the same stored procedure
Please guide me
|
|
|
|
|
Get the values from the UI and generate the XML string using .Net XML API class on the fly in the Business logic before sending it to the Stored Procedure.
Pass the generated XML string to the stored procedure.
In the stored procedure use the ntext to store the input XML string for further manipulation.
Sharp
Happy Programming
|
|
|
|
|
Hi,
I am working with SQL Server 2005. I have a created a database on my local machine, and would like to upload it to my hosting company. In the past the incrementing fields loose their IDENTITY so I had to go and manually set this property to be incremented by 1 each a new record is added.
So what I was thinking, maybe it is better if I just generated the SQL script of the tables, and run the script on the database online?? But then all of my records and data on the local machine isn't added into this script that generates the tables. How do I create INSERT statements that will take my current data and add it to the SQL Server at the hosting company.
This is the only way of doing it, is there maybe other ways??
Regards
ma se
|
|
|
|
|
SET IDENTITY_INSERT table on
insert
select
SET IDENTITY_INSERT table off
|
|
|
|
|
Hi,
I have no idea what you are trying to say here. I have a database on my local machine and I want to generate a script file that creates the tables and inserts the current values to the new database as well.
I hope you understand.
Regards,
ma se
|
|
|
|
|
I have a table in MS SQL Server 2005 containing two fields :-
TicketId and Narrative
The data within the table may look as follows
TicketId Narrative
-------- ---------
302523 FARMS
302523 UNIT 8420 KGS
302524 VEHICLE BREAKDOWN
302525 REPAIR SCHEDULE
Notice the first two records have the same ticket Id therefore are related.
I need setup a view the returns 1 record per ticket, concatenating related narratives together e.g.
TicketId Narrative
-------- ---------
302523 FARMS UNIT 8420 KG
302524 VEHICLE BREAKDOWN
302525 REPAIR SCHEDULE
Any help much appriciated
Steve Jowett
|
|
|
|
|
use function
create function abc(@TicketId char(x))
returns char(xxx)
as
begin
declare @ret char(xxxx)
declare @tmp table
(
....
)
insert into @tmp (...)
select ....
while ...
begin
...
set @ret = @ret + Narrative
end
return @ret
end
select TicketId,dbo.abc(ticketid) 'Narrative' from yourtable
|
|
|
|
|
MY finalized function, if anyone is interested :-
<br />
set ANSI_NULLS ON<br />
set QUOTED_IDENTIFIER ON<br />
GO<br />
CREATE FUNCTION [dbo].[ConcatNotes](@TicketId BigInt) <br />
RETURNS NVarChar(4000)<br />
AS<br />
BEGIN<br />
<br />
-- Declare the return variable here<br />
DECLARE @Narrative NvarChar(4000)<br />
DECLARE @Notes NVarChar(2000)<br />
DECLARE notes_cursor CURSOR FOR SELECT [Text] FROM Notes WHERE TicketId = @TicketId ORDER BY NoteId ASC<br />
OPEN notes_cursor<br />
FETCH NEXT FROM notes_cursor INTO @Notes<br />
SET @Narrative = ''<br />
WHILE @@FETCH_STATUS = 0<br />
BEGIN<br />
IF LEN(@Narrative) > 0<br />
BEGIN<br />
SET @Narrative = @Narrative + ' ¦ '<br />
END<br />
SET @Narrative = @Narrative + @Notes<br />
FETCH NEXT FROM notes_cursor INTO @Notes <br />
END<br />
<br />
CLOSE notes_cursor<br />
DEALLOCATE notes_cursor<br />
-- Return the result of the function<br />
RETURN LTRIM(@Narrative)<br />
END<br />
<br />
Then in my SELECT statement
SELECT TicketId, ConcatNotes(TicketId) AS Narrative FROM Tickets
Thanks to Zhengdong Jin for pointing me in the right direction
Steve Jowett
|
|
|
|
|
Sir,
In sql server 2005 for the particular column I want to get the auto increment property = true.But I don't know where that property is located.
Please help
|
|
|
|
|
In Sql Server Management Studio, Modify the table, View the column properties at the bottom, open the +Identity Specification and change (Is Identity) to Yes.
|
|
|
|
|
how to generate primary keys automatically in SQL Server2000 using enterprise manager
|
|
|
|
|
You have to do it yourself. It's not access. Insert a column, right click it and click Set Primary Key. You may also want to make the column autoincrement also.
ChrisB
|
|
|
|
|
Hi All
I just wanted to ask which is more optimal in terms of time & complexity.
1. Returning more than once to the database to retrieve some data
or
2. Getting all the data once & declaring a table at the database to store this data then getting the rows I want from this table & returning it as a string
Thanks a lot
Happy
|
|
|
|
|
i have pb connecting to remote sqlserver using asp.net the connection string i used
is
Dim sqlconn As SqlConnection = New SqlConnection("server=155.155.55.5;user id =try;password=try; database=db1")
the error i get is "sqlserver does not exist or access denied"
i check the authentication its correct...
i am not able to create obdc connectivity also for it ...
the sqlserver2000 is newly installed and just database is created.no other configurations done to database or tables.
thanks for help in advance .
waiting for your reply...
|
|
|
|
|
If the SQL 2000 installation includes SP3, then the default install disabled SQL authentication.
|
|
|
|