Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/sql-server-2008/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sql server 2008 将通配符提取到表中_Sql Server 2008 - Fatal编程技术网

Sql server 2008 将通配符提取到表中

Sql server 2008 将通配符提取到表中,sql-server-2008,Sql Server 2008,我想提取product表中的所有记录,其中product以字母N开头,并将其保存在名为List of N-Products的表中 我试过使用Select*from product,其中的产品为='N%' 试试这个 SELECT e.col INTO [ListofN-Products] FROM yourTable e WHERE e.col LIKE 'N%' SELECT * FROM [ListofN-Products] 希望它能帮助你 您可以执行如下简单的I

我想提取product表中的所有记录,其中product以字母N开头,并将其保存在名为List of N-Products的表中

我试过使用Select*from product,其中的产品为='N%'

试试这个

  SELECT e.col
  INTO [ListofN-Products]
  FROM yourTable e
  WHERE e.col LIKE 'N%'

  SELECT * 
  FROM [ListofN-Products]

希望它能帮助你

您可以执行如下简单的INSERT语句:

--Assuming all the column names are same in both tables
INSERT INTO [ListOfN-Products] 
SELECT p.*
FROM Product p
WHERE p.PRODUCTS like 'N%'
此外,正如不信者@Damien_所建议的,为什么不创建一个视图而不是一个表呢。与表不同,在基础表中插入新记录时,视图会自动更新

CREATE VIEW [ListOfN-Products]
AS
SELECT p.*
FROM Product p
WHERE p.PRODUCTS LIKE 'N%'

你能告诉我们你到目前为止都做了些什么吗?为什么是一张桌子而不是一个视图?不确定你为什么要把桌子放在最后?哦,对不起。此查询我为测试创建临时表此查询我现在将编辑我的查询谢谢。