|
Never Mind, I got it working. What I did was I ran the "print" script, pulled copied the result and rn it in Quer Analzer. It ran just fine and created all my Articles.
PS: I could not believe I was such a dork. But then again no where tells you that you need to run one script to create another.
Thanks guys.
OBTW: It would be nice if someone can explain wh I can not add a variable name to a stored procedure dnamically.
Greg
Coding makes the world go round!!!
|
|
|
|
|
how can i save the value of a field into a parameter in T-SQL?what i wrote is-
Create Procedure a_c
@C_Name varchar(100),
as
if exists(
select id as 'ID' from ABC where C_Name = @C_Name)
begin
----
end
else
begin
---
end
go
is this syntax correct?and should i declare 'ID'and how can i do it?
|
|
|
|
|
-- create proc
create proc abc
@para int output
as
set @para = 1
go
--exec proc
declare @p int
exec abc @p output
select @p
|
|
|
|
|
I have this info
Desc1................Desc2
-------------......----------
BudgetControl......RamonDilan
DirectorContr......JoseAleman
I wanna to show
Desc1................Desc2.............Desc1.............Desc2
-------------......----------......-------------...---------
BudgetControl......RamonDilan......DirectorContr...JoseAleman
Please help me on that.. Thanks
johnny
|
|
|
|
|
Try something like this:
<<tr>
<asp:repeater>
<td>Desc1 <br/><asp:Label ID="Desc1></td>
<td>Desc2 <br/><asp:Label ID="Desc2></td>
</asp:repeater>
</tr>
Sincerely,
Elina
Life is great!!!
Enjoy every moment of it!
|
|
|
|
|
Hi
Thanks for your response. But I using SQL Statements. I'm using SQL 2000 server in Query Analyser. Do you have any idea?.
Johnny
|
|
|
|
|
There are two options, using T-SQL to dynamically generate the query or use a join and eliminate null records.
If the join will work it is the best option as it is fast. The T-SQL option is usually ugly.
On two occasions I have been asked [by members of Parliament], 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?' I am not able rightly to apprehend the kind of confusion of ideas that could provoke such a question. - Charles Babbage
|
|
|
|
|
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
|
|
|
|