|
again, I tried to run the following query
INSERT INTO table1 (SID, Time) VALUES (1, SYSDATE)
but got the error message as below:
Msg 128, Level 15, State 1, Line 1
The name "SYSDATE" is not permitted in this context. Valid expressions are constants, constant expressions, and (in some contexts) variables. Column names are not permitted.
Can anyone tell me what the problem is? Thanks....
|
|
|
|
|
SYSDATE is an Oracle function. Use GETDATE().
The need to optimize rises from a bad design.
My articles[ ^]
|
|
|
|
|
i am working on SQL Server 2005(SQL Server Management Studio 2005).i want to ask that how can i import data from a text file into the table.i am really new to it,so please explain it in detail..
thanx..
|
|
|
|
|
Check out this link.[^] also check this google result[^]
I Love T-SQL
"Don't torture yourself,let the life to do it for you."
If my post helps you kindly save my time by voting my post.
|
|
|
|
|
Asks the same question in multiple forums, can't use Google, and can't understand that I am MOCKING him.
Blog link to be reinstated at a later date.
|
|
|
|
|
i am working on Visual Studio 2005 n SQL server 2005.i have written some data value in random order in a table,now i want that,when i access that table in a DropDownList then those values should appear in ALPHABETICAL ORDER...
kindly help..thanx a lot..
|
|
|
|
|
From memory, the dropdown list has a sort property? Or maybe use ORDER BY in your select?
Bob
Ashfield Consultants Ltd
|
|
|
|
|
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[ ^]
|
|
|
|