我需要为每行在两个数字之间生成一个随机数。
例如:
选择COLNAME, (随机号到2000 1500之间)从表名
提前致谢
看下面的代码,
Create table #test
(
id int primary key,
Name varchar(100)
)
insert into #test values (1,'John')
insert into #test values (2,'Walker')
insert into #test values (3,'Bob')
insert into #test values (4,'Tailor')
insert into #test values (5,'Phlip')
insert into #test values (6,'Kevin')
-- Query 1 :
update #test set name = 'Joney' where id = 1
-- Query 2 :
set rowcount 1
update #test set name = 'Joney' where id = 1
set rowcount 0
Run Code Online (Sandbox Code Playgroud)
我需要检查来自不同数据库的表的存在.我知道如何静态地执行此操作.但我想动态传递表名和数据库名.
所以这是期望,
Declare @tablename varchar(100) = 'testtable', @dbName Varchar(100) = 'TestDB',@isexist varchar(100)
If exists (select 1 from @dbName..sysobjects where name = @tablename)
Set @isexists = 'Table Exists'
Else set @isexists = 'Table do not exist'
Run Code Online (Sandbox Code Playgroud)