我有一张桌子.
---------
| a | b |
---------
| a | b |
---------
Run Code Online (Sandbox Code Playgroud)
我想将它旋转45度(顺时针或逆时针)并将其保存到另一张桌子中.例如,如果我逆时针旋转45度,它将是:
-------------
| b | | |
-------------
| a | b | |
-------------
| a | | |
-------------
Run Code Online (Sandbox Code Playgroud)
另一个例子,当我旋转
-------------
| a | b | c |
-------------
| d | e | f |
-------------
| g | h | i |
-------------
Run Code Online (Sandbox Code Playgroud)
它将变为
---------------------
| c | | | | |
---------------------
| b | f | | | |
--------------------- …Run Code Online (Sandbox Code Playgroud) 如何使用tsql获取sql server实例中的所有数据库名称?
我想替换ruby中最后一次出现的子串.什么是最简单的方式?例如,在abc123abc123中,我想将最后一个abc替换为ABC.我怎么能这样做?
在事务中包含select语句有什么意义?我认为select语句只是来自数据库的"GET"数据,它们没有机会回滚一些东西,因为你无法改变数据.那么,这是否说我们永远不需要在事务中放置select语句?我对吗?
谢谢.
我想填写需要开始和结束日期信息的日历对象.我有一列包含一系列日期.有些日期是连续的(有一天差异),有些则不是.
InfoDate
2013-12-04 consecutive date [StartDate]
2013-12-05 consecutive date
2013-12-06 consecutive date [EndDate]
2013-12-09 [startDate]
2013-12-10 [EndDate]
2014-01-01 [startDate]
2014-01-02
2014-01-03 [EndDate]
2014-01-06 [startDate]
2014-01-07 [EndDate]
2014-01-29 [startDate]
2014-01-30
2014-01-31 [EndDate]
2014-02-03 [startDate]
2014-02-04 [EndDate]
Run Code Online (Sandbox Code Playgroud)
我想选择每个连续日期范围的开始和结束日期(块中的第一个和最后一个).
StartDate EndDate
2013-12-04 2013-12-06
2013-12-09 2013-12-10
2014-01-01 2014-01-03
2014-01-06 2014-01-07
2014-01-29 2014-01-31
2014-02-03 2014-02-04
Run Code Online (Sandbox Code Playgroud)
我想只使用SQL来解决问题.
我有点困惑data consistency和data integrity.来自Oracle数据库概念:
data integrity
--------------
Business rules that dictate the standards for acceptable data. These rules
are applied to a database by using integrity constraints and triggers to
prevent invalid data entry.
Run Code Online (Sandbox Code Playgroud)
来自维基百科
Consistency
-----------
Consistency states that only valid data will be written to the database.
Run Code Online (Sandbox Code Playgroud)
那么data consistency和之间的区别是data integrity什么?
提前致谢.
如何在t-sql中使用group by with union?我想按联合结果的第一列分组,我写了下面的sql但它不起作用.我只是不知道如何引用union结果的指定列(在本例中为1).十分感谢.
SELECT *
FROM ( SELECT a.id ,
a.time
FROM dbo.a
UNION
SELECT b.id ,
b.time
FROM dbo.b
)
GROUP BY 1
Run Code Online (Sandbox Code Playgroud) 我知道在SO中有一个类似的问题如何在bash中用一个空行替换多行空行?.但我的问题是,这可以通过使用sed命令来实现吗?
谢谢
我在powershell中有一个字符串,其中包含一个本机sqlcmd命令.命令本身可以在cmd.exe中成功执行.我很难在powershell中执行它们.有人可以帮忙吗?谢谢.
这是sql.sql
select @@servername
go
select @@servicename
Run Code Online (Sandbox Code Playgroud)
这是从cmd.exe执行sqlcmd命令时的结果
C:\Users\test>sqlcmd -S "(local)\instance1" -U a -P a -i "c:\temp\sql.sql"
--------------------------------------------------
thesimpsons\INSTANCE1
(1 rows affected)
--------------------------------------------------
INSTANCE1
(1 rows affected)
C:\Users\test>
Run Code Online (Sandbox Code Playgroud)
这是用于调用sqlcmd命令的powershell脚本.
$sql = @"
sqlcmd -S "(local)\instance1" -U a -P a -i "c:\temp\sql.sql"
"@
Invoke-Command $sql
Run Code Online (Sandbox Code Playgroud)
当我执行此powershell脚本时,我收到以下错误.
PS C:\TEMP> $sql = @"
sqlcmd -S "(local)\instance1" -U a -P a -i "c:\temp\sql.sql"
"@
Invoke-Command $sql
Invoke-Command : Parameter set cannot be resolved using the specified named parame
ters.
At line:5 char:15
+ Invoke-Command …Run Code Online (Sandbox Code Playgroud) sql ×3
sql-server ×3
t-sql ×3
ruby ×2
transactions ×2
algorithm ×1
count ×1
database ×1
group-by ×1
matrix ×1
powershell ×1
sed ×1
sqlcmd ×1
string ×1
union ×1