Insert/Update/Delete with function in SQL Server
No, you cannot. From SQL Server Books Online: User-defined functions cannot be used to perform actions that modify the database state. Ref.
No, you cannot. From SQL Server Books Online: User-defined functions cannot be used to perform actions that modify the database state. Ref.
You don’t need to install SQL Server Express to use LocalDB, as LocalDB is SQL Server Express, just easier to install. Once LocalDB is installed you can use AttachDbFileName property of the connection string to “open” an MDF file. Keep in mind that the same file can only be opened by a single LocalDB instance … Read more
You can select the current_value from sys.sequences: SELECT current_value FROM sys.sequences WHERE name=”OrderNumberSequence” ; DEMO
The created column is simple – just a DATETIME2(3) column with a default constraint that gets set when a new row is inserted: Created DATETIME2(3) CONSTRAINT DF_YourTable_Created DEFAULT (SYSDATETIME()) So when you insert a row into YourTable and don’t specify a value for Created, it will be set to the current date & time. The … Read more
Add one more condition in where clause SELECT * FROM product WHERE pdate >= DATEADD(day,-30,GETDATE()) and pdate <= getdate() Or use DateDiff SELECT * FROM product WHERE DATEDIFF(day,pdate,GETDATE()) between 0 and 30
The thing about collations is that although the database has its own collation, every table, and every column can have its own collation. If not specified it takes the default of its parent object, but can be different. When you change collation of the database, it will be the new default for all new tables … Read more
It seems like the 32-bit version of Excel was not installed. Remember that SSDT is a 32-bit IDE. Therefore, when data is access from SSDT the 32-bit data providers are used. When running the package outside of SSDT it runs in 64-bit mode (not always, but mostly) and uses the 64-bit data providers. Always keep … Read more
Microsoft has changed the way they deal with identity values in SQL Server 2012 and as a result of this you can see identity gaps between your records after rebooting your SQL server instance or your server machine. There might be some other reasons for this id gaps, it may be due to automatic server … Read more
The primary key is a unique key in your table that you choose that best uniquely identifies a record in the table. All tables should have a primary key, because if you ever need to update or delete a record you need to know how to uniquely identify it. A surrogate key is an artificially … Read more
From CREATE TABLE: Local temporary tables are visible only in the current session and (more importantly): If a local temporary table is created in a stored procedure or application that can be executed at the same time by several users, the Database Engine must be able to distinguish the tables created by the different users … Read more