Manage PlItems
You may optionally enter a comparison operator (<, <=, >, >=, <> or =) at the beginning of each of your search values to specify how the comparison should be done.
Advanced SearchDisplaying 121-130 of 300 results.
ID | PlCodelang | PlGroup | PlItemTitle | Code | |
---|---|---|---|---|---|
63 | T-SQL | Datenbank | Tabellenstruktur kopieren | Select * INTO SQL2.dbo.NeueTabelle FROM SQL1.dbo.AlteTabelle WHERE 0=1 | ![]() ![]() ![]() |
64 | T-SQL | Datenbank | Prüfen ob temporäre Tabelle existiert | SELECT OBJECT_ID ('tempdb..#myTableTable1') | ![]() ![]() ![]() |
65 | T-SQL | Datenbank | Prüfen welche/ob Tabelle ein AutoIncrement/Identiy Spalte hat | -- Welche Tabellen ... select o.name, c.name, from sys.objects o inner join sys.columns c on o.object_id = c.object_id where c.is_identity = 1 -- -------------------------------------- -- Hat diese Tabelle ... IF ((SELECT OBJECTPROPERTY( OBJECT_ID(N'dbo.myTable'), 'TableHasIdentity')) = 1) PRINT 'Yes' ELSE PRINT 'No' | ![]() ![]() ![]() |
66 | T-SQL | Datenbank | Ausführen von SQL-Code per Aufruf | http://www.databasejournal.com/features/mssql/article.php/3286501/T-SQL-Programming-Part-4---Setting-Variables-in-Calling-T-SQL-Code-While-Using-spexecutesql.htm use Northwind go declare @RECCNT int declare @ORDID varchar(10) declare @CMD Nvarchar(100) set @ORDID = 10436 SET @CMD = 'SELECT @RECORDCNT=count(*) from [Orders]' + ' where OrderId < @ORDERID' print @CMD exec sp_executesql @CMD, N'@RECORDCNT int out, @ORDERID int', @RECCNT out, @ORDID print 'The number of records that have an OrderId' + ' greater than ' + @ORDID + ' is ' + cast(@RECCNT as char(5)) | ![]() ![]() ![]() |
67 | T-SQL | Datenbank | Tabellenzeile mit FK's löschen | -- Siehe auch: http://www.sqlteam.com/article/performing-a-cascade-delete-in-sql-server-7 CREATE Procedure spDeleteRows -- Recursive row delete procedure. -- It deletes all rows in the table specified that conform to the criteria selected, -- while also deleting any child/grandchild records and so on. This is designed to do the -- same sort of thing as Access's cascade delete function. It first reads the sysforeignkeys -- table to find any child tables, then deletes the soon-to-be orphan records from them using -- recursive calls to this procedure. Once all child records are gone, the rows are deleted -- from the selected table. It is designed at this time to be run at the command line. It could -- also be used in code, but the printed output will not be available. ( @cTableName varchar(50), -- name of the table where rows are to be deleted @cCriteria nvarchar(1000), -- criteria used to delete the rows required @iRowsAffected int OUTPUT -- number of records affected by the delete ) As set nocount on declare @cTab varchar(255), -- name of the child table @cCol varchar(255), -- name of the linking field on the child table @cRefTab varchar(255), -- name of the parent table @cRefCol varchar(255), -- name of the linking field in the parent table @cFKName varchar(255), -- name of the foreign key @cSQL nvarchar(1000), -- query string passed to the sp_ExecuteSQL procedure @cChildCriteria nvarchar(1000), -- criteria to be used to delete -- records from the child table @iChildRows int -- number of rows deleted from the child table -- declare the cursor containing the foreign key constraint information DECLARE cFKey CURSOR LOCAL FOR SELECT SO1.name AS Tab, SC1.name AS Col, SO2.name AS RefTab, SC2.name AS RefCol, FO.name AS FKName FROM dbo.sysforeignkeys FK INNER JOIN dbo.syscolumns SC1 ON FK.fkeyid = SC1.id AND FK.fkey = SC1.colid INNER JOIN dbo.syscolumns SC2 ON FK.rkeyid = SC2.id AND FK.rkey = SC2.colid INNER JOIN dbo.sysobjects SO1 ON FK.fkeyid = SO1.id INNER JOIN dbo.sysobjects SO2 ON FK.rkeyid = SO2.id INNER JOIN dbo.sysobjects FO ON FK.constid = FO.id WHERE SO2.Name = @cTableName OPEN cFKey FETCH NEXT FROM cFKey INTO @cTab, @cCol, @cRefTab, @cRefCol, @cFKName WHILE @@FETCH_STATUS = 0 BEGIN -- build the criteria to delete rows from the child table. As it uses the -- criteria passed to this procedure, it gets progressively larger with -- recursive calls SET @cChildCriteria = @cCol + ' in (SELECT [' + @cRefCol + '] FROM [' + @cRefTab +'] WHERE ' + @cCriteria + ')' print 'Deleting records from table ' + @cTab -- call this procedure to delete the child rows EXEC spDeleteRows @cTab, @cChildCriteria, @iChildRows OUTPUT FETCH NEXT FROM cFKey INTO @cTab, @cCol, @cRefTab, @cRefCol, @cFKName END Close cFKey DeAllocate cFKey -- finally delete the rows from this table and display the rows affected SET @cSQL = 'DELETE FROM [' + @cTableName + '] WHERE ' + @cCriteria print @cSQL EXEC sp_ExecuteSQL @cSQL print 'Deleted ' + CONVERT(varchar, @@ROWCOUNT) + ' records from table ' + @cTableName | ![]() ![]() ![]() |
79 | T-SQL | Datenbank, Collation | Datensatz Case-Sesitive abfragen | -- Table containing Values -- content (column) -- a -- A SELECT content FROM myTable WHERE content='A' COLLATE SQL_Latin1_General_CP1_CS_AS -- Result: A | ![]() ![]() ![]() |
80 | T-SQL | Datenbank, Collation | Collation (Sortierreihenfolge) einer Datenbank ändern | -- Collation einer Multi-User Datenbank ändern -- Über SSMS kommt die Fehlermeldung 5030 (Die Datenbank konnte nicht exklusiv gesperrt werden, um den Vorgang auszuführen.) -- siehe dazu: http://sunali.com/2009/10/08/microsoft-sql-server-error-5030/ -- the following line sets the database to "Single User" mode ALTER DATABASE MYDB SET SINGLE_USER WITH ROLLBACK IMMEDIATE -- the following line sets the new collation ALTER DATABASE MYDB COLLATE Latin1_General_CS_AS -- the following line sets the database back to "Multi User" mode ALTER DATABASE MYDB SET MULTI_USER | ![]() ![]() ![]() |
81 | T-SQL | Datenbank, Collation | Collation-Arten auflisten | -- siehe auch: http://msdn.microsoft.com/de-de/library/ms187963.aspx SELECT * FROM fn_helpcollations() | ![]() ![]() ![]() |
117 | T-SQL | Datenbank | CSV erstellen | SELECT SUBSTRING( (SELECT ',' + CSVItem FROM TableWithItems s ORDER BY s.Name FOR XML PATH('')),2,200000) GO | ![]() ![]() ![]() |
118 | T-SQL | Kontrollstrukturen | Switch / Case Anweisung | -- http://msdn.microsoft.com/de-de/library/ms181765.aspx USE AdventureWorks2008R2; GO SELECT ProductNumber, Category = CASE ProductLine WHEN 'R' THEN 'Road' WHEN 'M' THEN 'Mountain' WHEN 'T' THEN 'Touring' WHEN 'S' THEN 'Other sale items' ELSE 'Not for sale' END, Name FROM Production.Product ORDER BY ProductNumber; GO | ![]() ![]() ![]() |