|
Hello All,
I know it is out of scope of this group but I was wondering if anybody knows about AS400 whether or not it has a system database holding user_defined item names (tables fields etc).
Thanks alot.
|
|
|
|
|
Yes, it has all this information available in what is called the system catalog. You can get hold of the information through native commands like DSPFD or DSPFFD but you can also get hold of it via SQL queries if that's better for you. I'm a bit rusty with DB2/400 so I don't remember the exact table names to query but if you google for "AS/400 system catalog" you should find what you're looking for.
|
|
|
|
|
|
how to know current date and time.(i.e) date and time may vary across countries.how sql server will find the correct date and time.
|
|
|
|
|
Convert your DateTime to GMT; you'd convert every date you get from the user to GMT before sending it to the database. When reading the datetime from the database, adjust to the local timezone of the user. More information can be found on MSDN[^].
Good luck
I remain troll
|
|
|
|
|
|
Hi..
You can use the following:
SELECT GATEDATE() AS CURRENT_DATE
Md. Marufuzzaman
|
|
|
|
|
It would be "SELECT GETDATE()" but that would not work if the user is in a different timezone.
|
|
|
|
|
how to display exactly 2 digits after decimal point in money???
|
|
|
|
|
If you mean when selecting a value in SQL Server (using TSQL), you can use cast like this:
select cast([FIELDNAME] as decimal(10,2))
|
|
|
|
|
Check out STR function in BOL.
My other signature is witty and insightful.
|
|
|
|
|
Hi,
Suppose I have a number like 123456.98072340
My output should look like 123456.98 i.e. precisely 2 digits after decimal.
The query is:
SELECT CAST(ROUND(123456.98072340, 2, 1) AS DECIMAL(18, 2))
The generalised query will be
SELECT CAST(ROUND(InputNumber, N, 1) AS DECIMAL(18, N))
Where N=1,2,3,4,5,....
and it indicates the number of decimal places you want to display.
Hope this helps
Niladri Biswas
|
|
|
|
|
I didn't know whether to reply to my original question or post new - but as the original was asked (accidentally) under a different user name, I though I'd start a new thread. Apologies to anyone offended by that. (Original Here)[^]
I have sqlpubwiz 1.3 and it fails to script correctly on SQL Server 2008 if there are any foreign keys (or other constraints).
I'm kind of assuming this is something I am doing - as it's a pretty useless tool otherwise -
I have test db with two tables
CREATE TABLE [dbo].[Table_1](
[id] [int] NOT NULL,
[num] [int] NULL,
CONSTRAINT [PK_Table_1] PRIMARY KEY CLUSTERED
(
[id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
CREATE TABLE [dbo].[Table_2](
[id] [int] NOT NULL,
[num] [int] NULL,
CONSTRAINT [PK_Table_2] PRIMARY KEY CLUSTERED
(
[id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[Table_2] WITH CHECK ADD CONSTRAINT [FK_Table_2_Table_1] FOREIGN KEY([id])
REFERENCES [dbo].[Table_1] ([id])
GO
ALTER TABLE [dbo].[Table_2] CHECK CONSTRAINT [FK_Table_2_Table_1]
GO
Then I (try to) script it...
C:\Program Files\Microsoft SQL Server\90\Tools\Publishing\1.2> sqlpubwiz script -d myDatabase -S localhost\MYDATABASE -f .\test.txt
and get the error...
Microsoft (R) SQL Server Database Publishing Wizard
Version 10.0.0.0
Copyright (c) Microsoft Corporation. All rights reserved.
Generating script for database stit1
- Generating script targeted for SQL Server 2005
Gathering list of objects to script
Scripting objects
.....Error: Operation is not valid due to the current state of the object.
C:\Program Files\Microsoft SQL Server\90\Tools\Publishing\1.2>
Delete the foreign key and all is well.
I'd really appreciate it if someone could either confirm or deny the fact that this is 'just me' or, in fact, sqlpubwiz is a pile of donkey doo doo
___________________________________________
.\\axxx
(That's an 'M')
|
|
|
|
|
|
Hi Guys!
Am at my wits end! Please help me with any suggestions.
I have recently created a website for my father's Driving School which has database properties built in. I created it using Visual Web Developer 2008 and am now trying to make it possible for his clients to view any lesson dates and times of future lessons. Each client has their own username and password to access their own user area on the site. Obviously I want each client to be able to see their own times but not those of other clients. My father will be inputting the dates and times of all clients lessons himself.
How would I best go about this? My father is fairly IT literate, but would like all dates and times in a central database if possible. Please help. Many thanks.
|
|
|
|
|
Well, when your father saves the dates and times into the database, have him select a client from a dropdown list (so that he selects a valid client), then when your clients log into the system, store their ClientID in the session state or similar, and when selecting values from your database for lessons, restrict it by ClientID.
eg:
select LessonDate, LessonTime from tblLesson where ClientID = @ClientID
populating @ClientID with the ClientID of the logged in user.
|
|
|
|
|
This is my stored procedure
ALTER PROCEDURE TeamStructure
(
@rootid int
)
AS
WITH MyTeam
AS
(
SELECT *, [Name] AS ParentName, 0 AS TeamLevel FROM tbl_team
WHERE ParentID =@rootid UNION ALL
SELECT Fam.*,MyTeam.Name AS ParentName, TeamLevel + 1 FROM tbl_team AS Fam
INNER JOIN MyTeam ON Fam.ParentID = MyTeam.ID)
SELECT * FROM MyTeam
It will return the complete hierarchical records.
Level 0 will have root member
Level 1 will have 2 members
Level 2 willhave 4 members
Level 3 will have 8 members
or if level =n
members= 2^n
I need to perform the following operation:
for any level if members are less than 2^n the iteration should stop and return the number of members on that level and the number of level
For example if the number of members on level 4 are 12
The procedure should stop and return
level :4
Members :12
but if the number of members on nth level is exactly 2^n the iteration must look for the next level
Can anyone modify this procedure and help me please?
TIA
|
|
|
|
|
I have a Questions table in my database where the quuestiions are selected randomly using the following code
"public DataTable getQuestion(string concept,string questiontype)
{//gives the user the question for the concept selected above
string sql = "";
if (concept == "basic")
{
sql = "SELECT Question FROM Questions WHERE ConceptId LIKE 'BC%'AND QuestionType ='" + questiontype + "' Order by NewId()";
}
else if (Concept == "programming")
{
sql = "SELECT Question FROM Questions WHERE ConceptId LIKE 'PC%'AND QuestionType ='" + questiontype + "'Order by NewId()";
}
return dc.load(sql);//dc is an object of data connection class
}
Another question type is of multiple choice.And for this type of question there's an Options Table which I need to get the options of the question selected randomly using the code above. Any idea how I can do that? Please help.
ML Lingwati
|
|
|
|
|
Good day LucBite
Can you explain Briefly what is your Problem. i understand what you are trying to do, but can you tell us what exactly is your problem
Vuyiswa Maseko,
Few companies that installed computers to reduce the employment of clerks have realized their expectations.... They now need more and more expensive clerks even though they call them "Developers" or "Programmers."
C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.somee.com
http://www.vuyiswamaseko.tiyaneProperties.co.za
vuyiswa@its.co.za
http://www.itsabacus.co.za/itsabacus/
|
|
|
|
|
How do I select the options of a multiple choice question, for the multiple choice question that I selected randomly. Remember, I can't select the options randomly because they have to match the question even though the questiion is selected randomly. The questions are from the Questions Table and the options are from the Options Table. I hope I'm clear please help.
ML Lingwati
|
|
|
|
|
Good day LucBite
You did Explain Clearly again so that i cannot understand better, remember you showed us a Function that return a datatable, now when i said explain clearly i mean to tell us where does the parameters get passed from(UI or Another Function). I Assume you are trying to do something like this
You have a Testing Application, First you have Different type of Test "Basic", "Programming" and "MultipleChoice"
Now you can select Randomly for "Basic" and "Programming" But you cannot select Randomly for "MultipleChoice" So you want it to be able to select for "MultipleChoice" Questions Randomly"
This is how i understand it ,before i give you a solution , i would like to if am right else explain more give me more info
Vuyiswa Maseko,
Few companies that installed computers to reduce the employment of clerks have realized their expectations.... They now need more and more expensive clerks even though they call them "Developers" or "Programmers."
C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.somee.com
http://www.vuyiswamaseko.tiyaneProperties.co.za
vuyiswa@its.co.za
http://www.itsabacus.co.za/itsabacus/
|
|
|
|
|
LucBite wrote: hope I'm clear please help.
Not definitly not.
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.
|
|
|
|
|
So, for a multiple choice question type you want to return random questions and, for each of the questions returned, the applicable options?
If I were you, I'd change your sql to return 2 columns for multiple choice, the question text and the id (the primary key on the question table). From there, you can select the options from the appropriate table using the id of the question.
|
|
|
|
|
LucBite wrote: How do I select the options of a multiple choice question, for the multiple choice question that I selected randomly. Remember, I can't select the options randomly because they have to match the question even though the questiion is selected randomly. The questions are from the Questions Table and the options are from the Options Table. I hope I'm clear please help.
I'm not absolutely sure I understand your question, but this is what I think you might be asking for:
class SwitchTest
{
static void Main()
{
Console.WriteLine("Coffee sizes: 1=Small 2=Medium 3=Large");
Console.Write("Please enter your selection: ");
string s = Console.ReadLine();
int n = int.Parse(s);
int cost = 0;
switch(n)
{
case 1:
cost += 25;
break;
case 2:
cost += 25;
goto case 1;
case 3:
cost += 50;
goto case 1;
default:
Console.WriteLine("Invalid selection. Please select 1, 2, or 3.");
break;
}
if (cost != 0)
{
Console.WriteLine("Please insert {0} cents.", cost);
}
Console.WriteLine("Thank you for your business.");
}
}
"My interest is in the future because I'm going to spend the rest of my life there." - Charles F. Kettering
|
|
|
|
|
I have to panels in Splitter Container.One panel1 Contain Grid view and panel2 contain form having two textbox and two button.
When I selected row in grid view whice event will throw to return selected values of grid row in form(Textboxes).only to selected row time.......
if any one know answer reply immediatelly............
|
|
|
|