|
You can do it from SQl with
select ColumnName from my_table
Order by ColumnName Asc
Or you can do what is suggested by the other guy here.
Hope this helps
Vuyiswa Maseko,
Sorrow is Better than Laughter, it may Sadden your Face, but It sharpens your Understanding
VB.NET/SQL7/2000/2005
http://vuyiswamb.007ihost.com
http://Ecadre.007ihost.com
vuyiswam@tshwane.gov.za
|
|
|
|
|
History of posting same question in multiple forums and not using Google for basic questions.
Blog link to be reinstated at a later date.
|
|
|
|
|
Hi friends...
The requirement goes like this...
we already have 20 reports, like 1.rdl ,2.rdl.......20.rdl.
All reports takes a single parameter: @AssessmentId=Parameters!AssessmentId.Value
At present when client wants to view reports they have to click 20 different links for each report and then submit the assessmentid value as the parameter.
Now what they want is submit the parameter value in a single report and able to view all the reports one below another.
so how to go about this using sub reports
i am using sql server reporting services 2000. i have one shared datasource for all reports and different datasets.
thanx and regards
Hashmat
modified on Thursday, October 16, 2008 4:17 AM
|
|
|
|
|
Pull each sub report into the designer and set the parameters passed to each?
And nice naming convention...
|
|
|
|
|
Hi Paddy
As per you ,i have dragged a report(2.rdl) from the solution explorer into the designer of 1.rdl.It generated the sub report in the designer.
On right clicking sub report and selecting proerties ,I set the parameter as @AssessmentId=Parameters!AssessmentId.Value. which is same in report 2.rdl
now i m getting this error :
A parameter in the subreport ‘subreport1’ has the name ‘@AssessmentId’. Parameter names must be CLS-compliant identifiers.
how to resolve this error.
The other way i m thinking is copy and paste all tables in a single report and generate the report but i consider this as inefficient because must be better ways than doing this.
plz share ur thought on this.
|
|
|
|
|
SELECT Table1.AutoID,'RA No' = CASE WHEN Table1.RANo <= 9 THEN Table2.Assessment_Name + '/' + cast(Table1.Year_Year as varchar) + '/00' + cast(Table1.RANo as varchar) WHEN Table1.RANo >= 10 and Table1.RANo<=99 THEN Table2.Assessment_Name + '/' + cast(Table1.Year_Year as varchar) + '/0' + cast(Table1.RANo as varchar) WHEN Table1.RANo >= 100 THEN Table2.Assessment_Name + '/' + cast(Table1.Year_Year as varchar) + '/' + cast( + Table1.RANo as varchar) END,
'BU (consolidated Lev 1 - 4)' =
if len(Table1.BULevel1) <> 0 BEGIN SELECT Table1.BULevel1 + '/' from Table1 where len(Table1.BULevel1) <>0 END
if len(Table1.BULevel2) <> 0 BEGIN SELECT Table1.BULevel2 + '/' from Table1 where len(Table1.BULevel2) <>0 END
if len(Table1.BULevel3) <> 0 BEGIN SELECT Table1.BULevel3 + '/' from Table1 where len(Table1.BULevel3) <>0 END
if len(Table1.BULevel4) <> 0 BEGIN SELECT Table1.BULevel4 + '/' from Table1 where len(Table1.BULevel4) <>0 END
,Table1.RATitle AS [RA Name],Table1.RADesc AS [RA Desc],Table1.SME AS [SME],Tab_RiskRate.RiskRate_Name AS [Risk Rating (Pre Miti)],Tab_Location.Location_Name AS Location,Table1.PlannedMonth AS [Planned month],Table1.RescheduleMonth AS [Rescheduled Month],Table1.DateStarted AS [Date started],Table1.RAInitiated AS [No. of days since RA initiated],Table1.Signoff AS [Date Signed Off],Table1.ActualDate AS [Project Live Date],Tab_Status.Status_Name AS Status FROM Table1 INNER JOIN Table2 ON Table1.Assessment = Table2.AutoID INNER JOIN Tab_RiskRate ON Table1.PreMitigating = Tab_RiskRate.AutoID INNER JOIN Tab_Location ON Table1.Location = Tab_Location.AutoID INNER JOIN Tab_Status ON Table1.Status = Tab_Status.AutoID WHERE (Table1.Mode = 1)
i m getting Incorrect syntax near the keyword 'if'. and Line 8: Incorrect syntax near ','. error.
please guide me - KARAN
|
|
|
|
|
You if statement needs to be a case statement, much like the first line - can't have if statements inline like this. You might also want to revisit your design - this doesn't seem like the most logical structure.
|
|
|
|
|
how to restrict a value in a column like int 1000 to 2000 should only get inserted in the table otherwise that entry should not insert in the database.
|
|
|
|
|
A trigger might be your best bet here.
|
|
|
|
|
Contraints are the easiest way:
CREATE TABLE [dbo].[bob1](
[cola] [int] NOT NULL
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[bob1] WITH CHECK ADD CONSTRAINT [CK_bob1] CHECK (([cola] > 999 and [cola] < 2001))
GO
ALTER TABLE [dbo].[bob1] CHECK CONSTRAINT [CK_bob1]
This will only allow values between 1000 and 2000, otherwise you get an error
Bob
Ashfield Consultants Ltd
|
|
|
|
|
This is in alter statement how to do it in create statement .
|
|
|
|
|
That is the CREATE SCRIPT generated by Management Studio. I'm sorry, I didn't realise you wanted me to do ALL your work. Have you heard of Google, or perhaps Books Online, or even the HELP in Management Studio?
Bob
Ashfield Consultants Ltd
|
|
|
|
|
I can see his next post - how do I handle the exception when someone violates a constraint.....
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
I guess you're probably right...
Bob
Ashfield Consultants Ltd
|
|
|
|
|
I have three table A, B and C. Table A contain list of books borrow everyday. Table B contain the list of Books available in library. Table C suppose to have list of book not borrowed per day. I need a sample code to do this. I am using MS Access as my Backend database.
My Code is as follows:
"Insert into TableC (BookID,[Name], Author) (Select * From Table B where BookID) Not in (Select * from Table C where [Date] between ' " & TextBox1.Text & "' and ' " & TextBox2.Text & "'"
Thank you.
Thayhor
|
|
|
|
|
|
Paddy
I want to be able to get those books available in the School Library (Table A) and not yet borrowed (All the books borrowed entered into Table B) and copy the information to Table C every day. My query is given me "Syntax error in Insert Statement". I don't know how to go about this automatically.
NB: Table A,B and C have the following field in common 'BookID' 'Name' 'Author'
Thank you
|
|
|
|
|
It's a bit difficult to say what's the solution without seeing the table definitions. However, if I'm reading correctly, your problem is in syntax (I take it this gives an error). Perhaps something like following:
Insert into TableC (BookID,[Name], Author)
(Select BookID,[Name], Author
From TableB
where BookID Not in (Select bookID
from TableC
where [Date] between '" & TextBox1.Text & "' and '" & TextBox2.Text & "'" )) Also instead of using text concatenation for parameters, it's better to use bind variables (for example to prevent sql injection).
Hope this helps,
Mika
The need to optimize rises from a bad design.
My articles[ ^]
|
|
|
|
|
Thank you very much, but how can I use bind variable. A sample code will be appreciated.
Thayhor
|
|
|
|
|
The bind variable or parameter usage depends on how you are connecting to the database. If you're using ODBC, have a look at: OdbcParameter Class[^].
The need to optimize rises from a bad design.
My articles[ ^]
|
|
|
|
|
Sounds like your database design is broken.
Instead of having three tables "A - Borrowed", "B - All", "C - Not Borrowed". Consider having just "Books" with a column representing their status, ie: "Status: Borrowed / Not Borrowed / On Fire".
Then you might want to look at the "Relational" part of "Relational Database", and have "Books", "Borrowed Book", and "Client".
Also I'm not convinced that Access is an appropriate choice to run a loan desk....
|
|
|
|
|
How can I execute a function and then a stored procedure? The function gets the latest recordID and the the insert statement should execute and insert the recordID and value. My code looks like this:
CREATE PROCEDURE dbo.InsertCountry
(
@Country NVARCHAR(200)
)
AS
BEGIN
DECLARE @LastID = BIGINT
SET @LastID = (SELECT MAX(Country_ID) FROM Countries
IF @LastID IS NULL SET @LastID = '1'
ELSE SET @LastID = (@LastID) + 1
RETURN @LastID
END
BEGIN
INSERT INTO Countries
(
Country_ID,
Country
)
VALUES
(
@LastID,
@Country
)
END
The above code does not compile but when I take the first Begin and End block and put that in a function it works. I try to execute the function by using EXEC GetLastID but that does not work.
Illegal Operation
|
|
|
|
|
I have an UGLY suspicion that you are doing this completely wrong. CountryID should be an Identity field, you should not be attempting to populate the ID like this.
However try this
<br />
DECLARE @LastID = BIGINT<br />
SET @LastID = IsNull((SELECT MAX(Country_ID) FROM Countries),0)<br />
SET @LastID = (@LastID) + 1<br />
<br />
BEGIN<br />
INSERT INTO Countries<br />
(<br />
Country_ID,<br />
Country<br />
)<br />
VALUES<br />
(<br />
@LastID,<br />
@Country<br />
)<br />
END<br />
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Well, if it doesn't compile then the error message would have been useful, but it's never going to be reliable anyway.
Try this - and yes, there may be syntax errors for you to fix
CREATE PROCEDURE dbo.InsertCountry (
@Country NVARCHAR(200) )
AS
BEGIN
begin tran
INSERT INTO Countries
(Country_ID,Country)
select isnull(max(Country_ID),0) + 1, @Country
FROM Countries
commit
END
The reason it would never be reliable is because you could end up with 2 users executing it at the same time and getting the same id. By putting a transaction around it will prevent that.
BTW, your original code error was probably caused by RETURN @LastID , it would skip the rest of the code and exit the proc.
Bob
Ashfield Consultants Ltd
|
|
|
|
|
Here is my delema. A company row can have multiple representations in the security table, based on the priusa or prican values in the company table matching the iid values int he security table, or the values in company table being null, in which case i just want to match the cue of the first iid listed for the key in the security table.
The If section works if I change out the copmany.key references for a literal value, so as far as i can tell its having an issue with the assignment of the value to security.iid = (IF...).
Any ideas?
SELECT company.key, company.name, security.cue
FROM company LEFT OUTER JOIN
security ON company.key= security.key AND security.iid = (IF (select priusa FROM company WHERE key = company.key) is NOT NULL
BEGIN
select priusa FROM company WHERE key= company.key
END
ELSE
IF (select prican FROM company WHERE key= company.key) is NOT NULL
BEGIN
select prican FROM company WHERE key= company.key
END
ELSE
BEGIN
select TOP 1 iid FROM security WHERE key= company.key
ORDER BY security.iid
END)
WHERE (company.name like @name)
|
|
|
|