What is the effect of 'delete' on primary key and foreign key
when you have to delete the records on primary key and foreigh key then there is problem will hapen as primary key violation
at that time you have to provide delete rules when you create the tables
those are
1. on delete no action
2. on delete cascade
3. on delete set null
4. on delete set default
For primary key if that record is being refered by some other (Child Table) sql server won't let you to delete that record.While creating relationship if you had mention "Dele...
How to delete records from two tables. There is relationship between two tables.
It's working in MySQL but not in SQL-server.
For deleting the records from the relational tables there are 4 options available. These options can be used when you create the tables then you have to use these options and create tables and ...
Use a procedure which will delete record from child table first and then it will delete the same record from parent table
Same thing can be achieved using cascade delete and cascade update, this feature was not there in sql server 7.0
Query to find the list of employees age > 30
Write a query to find the list of employees whos age is greater than 30 or so given a date of birth column
Please tell me,
How to get age of all employee by using query
SELECT *,DATEDIFF(YY,
Thanks & Regards
K.santhosh
Can I retrieve column name using the column number of that column in the table? If yes then how?
No, It's not possible because select statement only selects the values.
Thanks & Regards
K.Santhosh
FOR EXAMPLE TO RETRIEVE 2ND COLUMN(ENAME) IN EMP TABLE:
SELECT
COLUMN_NAME FROM USER_TAB_COLUMNSWHERE
TABLE_NAME ='EMP'AND
COLUMN_ID = 2Syntax for getting the table witout any contents
create table emp as select * from student where 1=2;
select * from faculty where rownum=0;
Is there any way we can change the column name in a table
Answered by: Praveena
Answered On : Dec 14th, 2005Yes we can alter Column name in a table using the following query: alter
Regards,
Praveena
u can change the column name and also column definition that is whether the data type and its size by the ALTER command.
ALTER TABLE
yes, it's possible to change the column name by using the following query in SQL server
SP_RENAME ' <TABLE_NAME.OLD_COLUMN_NAME> ' , ' NEW_COLUMN_NAME '
Thanks & Regards
K.Santhosh
When do you use where clause and when do you use having clause?
Having clause is used when you want to specify a condition for a group function and it is written after group by clause. The where clause is used when you want to specify a condition for columns, single row functions except group functions and it is written before group by clause if it is used.
we have to apply the condition Before grouping the records then you have to use WHERE clause.
we have to apply the condition after grouping the records then you have to apply HAVING clause.
Thanks & Regards
K.Santhosh
The WHERE clause is a conditional construct used to restrict or limit rows based on some condition.If the condition is satisfied then the filtered rows are returned as output. Consider this exam...
What are various joins used while writing subqueries?
Self join-its a join foreign key of a table references the same table. Outer join--its a join condition used where one can query all the rows of one of the tables in the join condition even though they don't satisfy the join condition.Equi-join--its a join condition that retrieves rows from one or more...
There are 5 types of joins. Those are
1. Equi Join / Inner Join
2. Non-Equi Join
3. Outer Join ( Left Outer Join, Right Outer Join, Full Outer Join )
4. Self Join
5. Cross Join
Two join conidtion we can use for subqueries:
Equi Join,
Self Join
create table #temptable(rowid int,colorname varchar(25),Hexa varchar(7),R tinyint,G tinyint,B tinyint) GO insert into #temptable values(1,'Violet','#8B00FF',139,0,255); insert into #te...
Use decode function.