Remove Enums from list if they already exists in database

I have a database table called DynamicText with the fields of ID, Content, and TypeEnum. I have a list of Enums called DynamicTextEnums and I want to ensure that there is only one record per Enum in the database. Example: I have 3 Enums called Red, White, and Blue. When creating a new record, I […]

checktable with repari_allow_data_loss taking so much time

I am not sure whats going on. But, When i run alter database myDatabase set emergency ALTER DATABASE myDatabase SET SINGLE_USER WITH ROLLBACK IMMEDIATE dbcc checktable (‘myTable’, repair_allow_data_loss) alter database myDatabase set multi_user Its taking so much time. (running for last 30 minutes and still running) Can anyone tell me, is something going wrong or […]

Multiple Outer joins return top result

I have a query with several left outer joins, for simplicity sake I will just include the two. It looks something like this: SELECT Object.ID,, Gloss.order, from Object LEFT OUTER JOIN Gloss on Gloss.object_id = Object.ID LEFT OUTER JOIN Title on Title.object_id = Object.ID However, some items have multiple Gloss, and I want […]

linq with entity framework – translate from SQL

I want to translate the following request to linq with entity framework: SELECT * FROM productivite INNER JOIN Clients ON Clients.ClientName = productivite.action and Clients.Responsable =’resp1′ How can I do that?

Multiple String Search and Replace on SQL Server (for templates)

I have a database table that has template html, formatted as “text {var1} text {othervar}”. I would like to apply the string substitutions in a more pragmatic way than: set @template = replace(@template, ‘{var1}’, field.value); set @template = replace(@template, ‘{othervar}’, field.othervalue); — notice I don’t have matching template variables and data fields There are dozens […]

SQL (NOT IN) Query takes forever to execute

I have a query which takes more than 2 hrs to execute for million records, I am not sure how I can optimize it to make it run little faster. Here is the sql fiddle for the table and the query. WITH frm AS (SELECT product_id AS PId, Min(Cast(product_startdate AS DATETIME)) AS PStartDate FROM products […]

CFML sql query modifying original date format from table

Say I have the following date format in my SQL Server database: 3/2007 but when I try to get the data via CFML script I get it this altered format 2007-03-31 00:00:00.0, my script looks like this: <cfquery name=”header” datasource=”mydb”> SELECT ExpDate FROM myTable </cfquery> <CFOUTPUT>ExpDate</CFOUTPUT> <cfloop query=”header”> <CFOUTPUT>#ExpDate#</cfoutput> </cfloop> Any idea why my date […]

Doing a bulk insert with C#?

I am trying to do a bulk insert with C#. I saw some simple code for the case when number of columns in source csv is same as destination table. I have a csv file which I want to insert into specific columns of a destination table. In my case, the number of columns in […]

SQL Server connection on distributed Access front end

I’m working on an application right now that requires a link to a couple of SQL Server tables. My windows network account has permission to connect to this server, but I am not going to be the only one using this application. I’m going to send it out for people to save to their PC […]

SQL server Rank function by week

I am still learning about SQL Server, and recently I encountered with issue with ranking (not sure if i should use rank). I am trying to get the ranking to sort out as below, but i could not achieve by using row_number(over) or any ranking function in SQL server. [Add in ] the content in […]

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