`

use database function

阅读更多

 

1.return int type function

 

ALTER FUNCTION [dbo].[Foo]()
RETURNS int
AS
BEGIN
    declare @n int
    select @n=3
    return @n
END

------test------------
SELECT dbo.foo()

 

 

2.select user info by max id

 

 

CREATE FUNCTION getmax()
returns varchar(50)
AS
begin
    declare @name varchar(50)
    select @name = [name] from record where id=(select max(id) from record)
    return @name
end

 

-------test-------
SELECT * FROM record where name =(dbo.getmax())

SELECT dbo.getmax()

 

 

 

分享到:
评论

相关推荐

    Absolute Database for D7

    This BDE replacement is the compact, high-speed, robust and easy-to-use database engine. With Absolute Database you will not need special installation and configuration, it compiles right into your ...

    Database design & Database deployment software BDB 2007 Professional V2.3

    Its definition documents use XML standard formats, and open the original program of the database structure (C#,Delphi,JAVA) for External readers. By using BDB, you can simplify software development ...

    Database design & Database deployment software BDB 2007 Developer V2.3

    Its definition documents use XML standard formats, and open the original program of the database structure (C#,Delphi,JAVA) for External readers. By using BDB, you can simplify software development ...

    Dimeric.Virtual.Database.

    In VDB you would use the [now()] function. If you were connecting to Informix, this would be translated into CURRENT or getdate() for SQL Server. This makes code written to VDB more portable across ...

    Laravel开发-laravel-scout-database

    composer require beyondcode/laravel-scout-database ``` 然后,在 Laravel 的 `config/scout.php` 配置文件中,选择 `database` 作为默认驱动: ```php 'driver' => 'database', ``` **3. 创建索引和模型关联**...

    Laravel开发-laravel-postgis-database

    use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; class CreateLocationsTable extends Migration { public function up() { ...

    Laravel开发-laravel-database-influxdb

    use Spatie\InfluxDB\Eloquent\Model; class Measurement extends Model { protected $测量字段 = ['field1', 'field2']; // 可选:指定时间戳字段 protected $timeStamp = 'timestamp_field'; } ``` 这里的 ...

    SQL sever 实训

    USE Xk GO SELECT * FROM Course --有哪些种类的选修课?学分是多少 USE XK GO SELECT Kind,Credit FROM Crouse GO 修改列名字 SELECT '课程种类'=Kind,'学分'=Credit FROM Course GO --查询Course表的前10行 ...

    Laravel开发-laravel-plus-database

    use App\User; // 假设User是模型类 // 创建新记录 $user = new User; $user->name = 'John Doe'; $user->email = 'john@example.com'; $user->save(); // 查询记录 $users = User::all(); // 获取所有用户 $user ...

    Oracle Database 10g PL-SQL Programming

    - **Function Creation**: Writing and using functions to return values. - **Package Creation**: Creating packages to encapsulate related procedures and functions. - **Overloading**: Allowing multiple ...

    Laravel开发-search-client-database-eloquent

    use Illuminate\Database\Eloquent\Model; class User extends Model { // 如果表名不是模型名称的复数形式,可以在这里指定 protected $table = 'users'; // 定义可填充字段 protected $fillable = ['name',...

    Source-Navigator

    The database represents internal program structures, locations of function declarations, contents of class declarations, and relationships between program components. Source-Navigator graphical ...

    Laravel开发-postgresql-schema

    use Illuminate\Database\Migrations\Migration; class CreateParentTable extends Migration { public function up() { Schema::connection('pgsql')->raw("CREATE TABLE parent_table (id SERIAL PRIMARY KEY)...

    Laravel开发-laravel-crud

    use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; class User extends Model { use HasFactory; } ``` 接着,创建一个数据库迁移文件来定义表结构: ```php ...

    Laravel开发-eloquent-mongodb-repository

    'database' => env('MONGO_DATABASE', 'database'), 'username' => env('MONGO_USERNAME', ''), 'password' => env('MONGO_PASSWORD', ''), 'options' => [ 'database' => 'admin' // sets the authentication ...

    Laravel开发-uniquely

    use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Uuids\Uuid; class YourModel extends Model { use Uuid; protected $keyType = 'string'; public $incrementing = false; ...

    08-谷歌面试题-08-谷歌面试题

    在面试题中,我们可以看到基本的数据库操作命令,如create database、use database、create table、insert into、select等。这些命令都是数据库管理系统(DBMS)中的基本操作。 * create database:创建一个新的...

    Laravel开发-uuid

    use Illuminate\Database\Eloquent\Model; use App\Utils\UuidGenerator; class MyModel extends Model { protected $fillable = ['name', 'description']; protected static function boot() { parent::boot...

    Laravel开发-l5-fixtures

    use Illuminate\Foundation\Testing\DatabaseTransactions; class ExampleTest extends TestCase { use DatabaseTransactions; public function testUserCreation() { $this->loadFixtures('users.yaml'); ...

Global site tag (gtag.js) - Google Analytics