Tag: sql-server

How Can I Get An Exact Character Representation of a Float in SQL Server?

We are doing some validation of data which has been migrated from one SQL Server to another SQL Server. One of the things that we are validating is that some numeric data has been transferred properly. The numeric data is stored as a float datatype in the new system. We are aware that there are […]

Insert 2 values from two different tables into one table

I have a problem with insert 2 values from 2 different tables during inserting to third table. First table is: author_id (PK) author_name author_email Second table is: category_id (PK) category_name Third table is: post_id post_category post_author post_title post_content post_date and I want get author_name from the first table and category_name from the second table during […]

SQL server select distinct latest values by inner joining three or more table

In my data base I have these tables each and every table has nearly 200,000 rows in it. User table: ╔════════╦══════╦═════════════╗ ║ UserID ║ Name ║ Email ║ ╠════════╬══════╬═════════════╣ ║ 1 ║ ABC ║ abc@abc.com ║ ║ 2 ║ DEF ║ def@def.com ║ ║ 3 ║ XYZ ║ xyz@xyz.com ║ ╚════════╩══════╩═════════════╝ Vacancy table: ╔════════════╦═════════════╗ ║ […]

Entity Framework Code First – One to Many relations from multiple tables

I have a BlobEntity table that contains paths to files for many other tables (tableX, tableY, tableZ, etc…) in my application. The relation between all the other tables to BlobEntity table is one to many. Example: tableX -> BlobTable (OTM) tableY -> BlobTable (OTM) tableZ -> BlobTable (OTM) and the relation is: public virtual ICollection<BlobEntity> […]

SQL: Delete all nested self referencing records

This is the structure of a table: Id Name ParentId ParentId is a foreign key to primary column Id. Now lets say I have a few rows like: (Only showing ParentId from rows) 01 / \ 5 2 / \ 3 4 I have setup InsteadOfDelete trigger as seen below: CREATE TRIGGER [dbo].[tr_tb] ON [dbo].[Some_tb] […]

Why does Entity Framework fire two SQL queries when simply fetching table rows?

I am using Entity Framework 6.1.3, when i fetch the user by username/password as shown below. EF actually fires two SQL queries to the database. I used SQL Server Profiler to inspect the query calls. By preventing second call I can reduce the execution time. C# code: Dim oSelectedUser As User = (From oUser As […]

SQL view without locking

We have a table with three columns: id, fieldName, fieldValue. This table has many records. We want to quickly access a list of the distinct fieldNames. When we create a view with a clustered index, we get this, but we have another problem: we have many processes that delete from the table by the id […]

SSISDB logical consistency-based I/O error

Suddenly my SSISDB got error, the error message is : SQL Server detected a logical consistency-based I/O error: incorrect checksum (expected: 0x7b1871bc; actual: 0x731871bc). It occurred during a read of page (1:156948) in database ID 11 at offset 0x0000004ca28000 in file ‘D:\SQL\MSSQL12.PALOMAGROUPBI\MSSQL\DATA\SSISDB.mdf’. Additional messages in the SQL Server error log or system event log may […]

sql server update table

the table: CREATE TABLE [dbo].[User] ( [UserName] NVARCHAR (100) NOT NULL, [Pasword] NVARCHAR (100) NOT NULL, [Name] TEXT NOT NULL, [LastName] TEXT NOT NULL, [Location] TEXT NOT NULL, [profesion] TEXT NOT NULL, [Email] NVARCHAR (50) NOT NULL, [Gender] TEXT NOT NULL, PRIMARY KEY CLUSTERED ([UserName] ASC) ); i want to update to: CREATE TABLE [dbo].[User] […]

SQL Connection String Security

We have a internal asp.net website running on IIS with Windows Security. From what I understand (and observe) this means that each thread runs using the credentials of the user who connects to the website. The website connects to a SQL Server 2014 database. We use a SQL Server username and password to make the […]

MS SQL Server is a Microsoft SQL Database product, include sql server standard, sql server management studio, sql server express and so on.