簡體   English   中英

SQL 腳本制作另一個 SQL 腳本

[英]SQL script to make another SQL script

我需要一個 SQL 腳本,它根據 ID 讀取表中的數據,然后生成另一個 SQL 腳本。 生成的腳本應該能夠更新和插入以前由 ID 選擇的數據。

我知道更新和插入命令,但我不知道如何創建一個從現有數據構建腳本的腳本。 任何人都可以幫忙嗎?

不知道你想在這里完成什么。

在這里,我使用查詢來查找要更新的 id。 update table set updated=now() where id in (select id from table where updated is null);

Here I create a query that I run (command differs depending on sql engine, you have to google yours) SET SQL = select 'select * from table where id = ' + select max(id) from table where updated is null; -- 將生成類似'select * from table where id = 2' SELECT SQL; -- 打印將運行 exec(SQL) 的查詢; -- 運行你生成的查詢

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM