使用SQL Server,如何拆分字符串以便访问项目x?
拿一个字符串"Hello John Smith".如何按空格分割字符串并访问索引1处应该返回"John"的项目?
SQL Server问题:
我有一个表,其中包含一个包含外键列表的列
| ID | PRICE | LIST_OF_FOREIGN_IDS |
------------------------------------
| 3 | 89 | 67,68,69 |
| 4 | 120 | 45,46 |
Run Code Online (Sandbox Code Playgroud)
我需要一个带有单个ID且FOREIGN_ID每行一个的视图.
| ID | PRICE | FOREIGN_ID |
---------------------------
| 3 | 89 | 67 |
| 3 | 89 | 68 |
| 3 | 89 | 69 |
| 4 | 120 | 45 |
| 4 | 120 | 46 |
Run Code Online (Sandbox Code Playgroud)
有没有人知道一个解决方案来获取第二个表中的数据?
我想从一个表中获取包含输入字符串中至少一个单词的所有记录.例如,input parameter =' Stack over flow ':
select *
from sample
where name like '%stack%'
or name like '%over%'
or name like '%flow%'
Run Code Online (Sandbox Code Playgroud)
如何搜索包含'stack'或'over'或'flow'的记录?
我的SQL Server表结构是:
BranchName
BranchManagerName
Address
Zip Info
PhoneNo
FaxNo
Email
Status
CreatedOn
Run Code Online (Sandbox Code Playgroud)
现在,我尝试通过值Zip Info列一样State=XXXX,city=YYYY,Zip=123三个值.
我需要这三个值(State,City,Zip)存储在sql表格中的Zip Info格式state,city-Zip(xxxx,yyyy-123)列中.
如何在SQL Server 2005中编写插入查询?