Решение: DECLARE @input VARCHAR(11) = '2323' select CAST(CASE WHEN @input NOT LIKE '%[^0-9]%' THEN @input END AS INT) DECLARE @input2…
Решение: EXEC sp_msforeachtable "ALTER TABLE ? NOCHECK CONSTRAINT all" Подробнее: If you want to disable all constraints in the database…
Решение: This is a quick run through to generate Insert statements for all of the data in your table, using…
Решение: Сама функция: CREATE FUNCTION SalesByStore (@id int) RETURNS TABLE AS RETURN (SELECT * FROM bsh_products WHERE partID=@id) Вызов: ALTER…
Решение: sp_columns 'as_menuRoles' SELECT * FROM syscolumns sc JOIN sysobjects so ON sc.id = so.id WHERE so.Name = 'as_menuRoles' select…
Решение: db.ExecuteStoreCommand(string.Format(@" BULK INSERT [{1}] FROM '{0}' WITH ( DATAFILETYPE = 'widechar', FIELDTERMINATOR = '|', ROWTERMINATOR = '\n' );", p,tablename)…
Решение: db.ExecuteStoreCommand(string.Format(@" BULK INSERT [{1}] FROM '{0}' WITH ( DATAFILETYPE = 'widechar', FIELDTERMINATOR = '|', ROWTERMINATOR = '\n' );", p,tablename)…
Решение: использование SET IDENTITY_INSERT testIdentity ON; USAGE-HOW-TO: CREATE TABLE testIdentity (id int IDENTITY (1,1), name nvarchar(100)); INSERT INTO testIdentity(name) VALUES…
Решение: SELECT od2.ProductID, COUNT(od2.ProductID) AS Rank FROM OrderDetail od1 JOIN OrderDetail od2 ON od1.OrderID = od2.OrderID WHERE od1.ProductID = 4…
Решение: SELECT Col1, Col2, CASE WHEN Col1='AAA' THEN Col2 WHEN Col1='BBB' THEN Col2*2 ELSE NULL END AS Col3 FROM ...…