I want to have the following query: SELECT COUNT(*) FROM MyTable WHERE CONTAINS (MyField, '(429)') The problem, is that the parenthesis are ignored and it is
I have created a view which uses dynamic variables in the where statement below. DECLARE @wkFileYear SMALLINT = (select fs.FileYear from dbo.FileSemesters fs
I need to do an Select on a table that has many records to mask the Account Number. Example AccNumber : 123400012341234 Output result should look like 1234000
I've got two foreign keys in a table. Let's assume that table is called News and has foreign keys updatedById and createdById, both of which point to userId in
For my unit tests I have an automated process which builds a copy of a DB, table by table. I first of all run a SELECT INTO and add the primary key and any indi
I have a table with a column like this that is currently live: name NVARCHAR(128) NOT NULL DEFAULT '' I am altering the column like this to make it nullable:
How to write a query to just determine that the values in a column are unique?
I have 2 commands and need both of them executed correctly or none of them executed. So I think I need a transaction, but I don't know how to use it correctly.
I have a table where all columns are auto-populated whenever an insertion happens: CREATE TABLE … ( ItemID INT NOT NULL IDENTITY(…
I really don't care what I do with this test database...it's for sandbox testing (attached to a production server instance)! All I'm trying to do is KILL all co
I can't seem to find an answer to this anywhere --- I want to convert a datetime in SQL to the excel serial number. I'm essentially looking for the DATEVALUE f
I inherited some old stored procedures today, and came across several examples that followed this general pattern, where @Test is some INT value: IF @Test IS N
I am using OleDb, trying to do this: Dim d as Date = DateSerial(Year(rptDate), Month(rptDate), 1 - 1) Dim conn as OleDbConnection = new OleDbConnection(connSt
I have been getting the following error when running a SQL to convert my data type value from varchar to datetime. Msg 242, Level 16, State 3, Line 1 The
I would like to export whole database schema to XML file. Information there what are needed. tables - columns, data type, pk, fk, views - returned columns, fun
How can I emulate MySQL's CONCAT_WS() function in SQL Server? This function is similar to CONCAT() function in SQL Server 2012 except that it adds a separator
I am using this script below to create a function but I get an error in the messages log: CREATE FUNCTION [dbo].[MyFunction] () RETURNS BIT AS RETURN CAST(1 AS
I am trying to rearrange Invoice date field of YYYMMDD into short date format DD/MM/YYYY or DD-MM-YYYY UK/British format in a SELECT statement. Performing on
Is there an method for programmatically (in T-SQL) retrieving the maximum (and minimum) value of a datatype? That it would act like float.MaxValue in C#. I wou
Is there an method for programmatically (in T-SQL) retrieving the maximum (and minimum) value of a datatype? That it would act like float.MaxValue in C#. I wou