Queries

  • October 2019
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View Queries as PDF for free.

More details

  • Words: 336
  • Pages: 3
create procedure debuga ( @intin int, @intout int output ) as set @intout = @intin + 10 return

declare @newint int exec debuga 5,@newint output select @newint

--multiple update statements in sql query update emp set salary=(case when salary>5000 then salary+1000 when (salary>=2000 and salary<=3000) then salary+1000 when (salary>=0 and salary<=1000) then salary+500 else salary+1000 end)

case case is used to replace occurrences of one value with other values, as specified by the programmer select job_desc, salary_level = case when job_desc = 'new hire - job not specified' then '25k' when job_desc = 'chief executive officer' then '500k' when job_desc = 'business operations manager' then '350k' when job_desc = 'chief financial officier' then '400k' when job_desc = 'publisher' then '75k' when job_desc = 'managing editor' then '65k' when job_desc = 'marketing manger' then '55k + commissions' else 'you get the idea' end from jobs select city, coalesce(state, 'no state specified') as state from publishers

select app_name()-sql query analyser select db_name()-ipro_dev select

top 10 title_id, isnull(royalty, 0) as royalty from titles

cast(expression as new_data_type) convert(new_data_type, expression, [style]

select top 1 cast(ord_date as varchar(12)) from sales

select top 1 convert(varchar(12), ord_date, 109) from sales into select * into test from emp select empid into test from emp select * from test

@@identity returns the last identity value inserted on the current connection the ident_current() function accepts a table name as the parameter and returns the last identity value generated in that table by any connection the scope_identity() function takes no parameters and returns the last identity value inserted within the current scope.

the current_user, system_user, user_name(), and session_user functions return information about the current user of the system. select select select select

current_user-ipro_dev system_user-ipro_dev session_user-ipro_dev user_name()-ipro_dev

host_id() and host_name() return workstation identifier and name, respectively. select host_id() select host_name()-system9

select

isdate('february 39, 2002') as 'february 39, 2002', isdate('1/1/2002') as '1/1/2002', isnumeric('abc') as 'abc', isnumeric('123') as '123' february 39, 2002 1/1/2002 abc 123 0

1

0

1

select getdate()-date and time function select current_timestamp-system function

select charindex('.','2.4') select substring('srini',1,2)

Related Documents

Queries
April 2020 7
Queries
May 2020 14
Queries
October 2019 20
Queries
November 2019 22
Queries
August 2019 35
Oracle Queries
June 2020 2