This "1432443679" is my string which is stored in a column called Due_date. I need to convert this to a datetime using dateadd function by the below formula. When I applied this in Excel workbook I get datetime as "5/24/2015 5:01:19".
I am looking for a way to update (.modify('insert into..') to be specific) an XML column in a table with xml fragments from another table linked by a foreign key. For example, my table structure looks like below (simplified): Fields 1 to 5 in each ta
Here is an example of my current table: ProjectID Level Cost --------- --------- --------- 101 LVL_1 1000.00 101 LVL_2 2500.00 102 LVL_1 1500.00 102 LVL_2 3000.00 103 LVL_2 1200.00 When I run the following query: SELECT ProjectID, CASE WHEN Level = '
This is my query INSERT INTO Tbl_DomainWiseStats (subdomainid, tendercount, Type_cat, DisplayText) SELECT ' + CAST(@domain_id AS VARCHAR(100)) + ' , TenderCount , ''ByCountry'' ,Country FROM (SELECT DISTINCT V.Country, COUNT(DISTINCT Sr_No) as Tender
I have a table with routes and I need to give them actual orders. The data looks as follows: route | rstart | rfinish | rfrom | rto | rorder -------------------------------------------------- route1| A | E | A | B | 0 route1| A | E | B | E | 0 route2
Given declare @text varchar(4) ='3677.98*' , @text2 varchar(4) ='1245367.98%' I want the output as follows: 3,677.98* and 1,245,367.98% I tried below: select convert(varchar,cast(3677.98 as money),1) --output as 3,677.98 If I try select convert(varch
I want to select nth record randomly from 100 of records by using select query in SQL ServerHere is a one-query solution: select top 1 t.* from table t order by newid();
I would like to select rows based on specific column values and a unique id column in SQL The Table I have is as follows Acc_id | Name | Status | value ---------------------------------------- 101 | com | Active | 1 202 | net | Active | 2 202 | net |
I have an sql table like this: Table Users Id Name Country rank total +----+---------------+---------------+-----------------+-------------+ 1 John Canada 2 Kate Canada 3 Mark Canada 4 Max Argentina 5 Sam Argentina 6 Stacy China 7 Ken China 8 jack Ch
I'm having a sql table with date column named CREATED_TS which holds the dates in different format eg. as shown below Feb 20 2012 12:00AM 11/29/12 8:20:53 PM Feb 20 2012 12:00AM 11/29/12 8:20:53 PM Feb 20 2012 12:00AM 11/29/12 8:20:53 PM Nov 16 2011
Right I have the following data which i need to insert into a table called locals but I only want to insert it if the street field is not already present in the locals table. The data and fields are as follows: Street PC Locality --------------------
I am loading data from Excel Source to SQL Server destination. And it is working fine. The problem is the empty rows are also inserting into the database. Can you help please. ThanksCheck the step 7 of article he has used conditional splits you can u
I'm trying to fetch data from my Local-Server Using an Android App. I established this using jtds.jdbc Connection. In Emulator It's working fine and fetching Data. While tried to connect using Android device through USB it's Giving the Following Erro
How to add a column to a SQL Server table with a default value that is equal to value of an existing column? I tried this T-SQL statement: ALTER TABLE tablename ADD newcolumn type NOT NULL DEFAULT (oldcolumn) but it's giving an error: The name "oldco
I want to use a stored procedure to copy a table from my test database to a linked server with the same ID's / Identity but I can't get it to work.. I've set the IDENTITY_INSERT to ON but it still complains about the ID column. Here's my procedure: C
DECLARE @d DATETIME = '01/01/2011'; SELECT FORMAT ( @d, 'd', 'en-US' ) AS US_Result; I am using above code in SQL Server 2008 R2 but it is encountering an error: 'FORMAT' is not a recognized built-in function name. How can I use FORMAT function?FORMA
description_id description -------------- ------------- 1 Ampicillin Oral 1 Ofloxacin Oral 1 Sulfamoxole+Trimethoprim Oral 2 Letrozole Oral 2 Flunarizine Oral description_id from table1 and description from table2. and result should be description_id
How do I change this SELECT so it is the criteria used for deleting? SELECT COUNT(empid), empid, status, deptid from tableA GROUP BY empid, status, deptid HAVING status is null and deptid = 5 What do you want to delete? If simply records with NULL st
My table looks like: A B C D 1 1 1 1 1 1 3 2 1 1 0 4 1 1 2 1 1 2 1 0 1 2 0 2 1 2 4 5 2 1 5 3 My goal is to, for each pair of A and B, output the value in D that corresponds to MIN(C), and the value in D that corresponds to MAX(C). The output should b
I have some orders in a table and the last order date of 2011 is 20th Dec. I'm using a sql command to calculate the number of orders in a given week: SELECT CONVERT(VARCHAR(3),DATENAME(week,convert(datetime,order_date,103))) AS week, COUNT(1) as orde
I have a table A that has primary key Id. I want to find all tables that contain this key as foreign. Number of tables is about 100, so its rather impossible to use generated database diagram. Is it any way to to query database schema objects to find
I am trying to get the hierarchy level of this query. Here is the CTE recursive query WITH CategoryRec AS ( SELECT Id, Parentid, Name FROM dbo.Category UNION ALL SELECT cr.Id, c.Parentid, cr.Name FROM CategoryRec AS cr INNER JOIN dbo.Category AS c ON
I can call SQL server 2008 from PHP with Microsoft Drivers for PHP for SQL Server ( http://www.microsoft.com/download/en/details.aspx?id=20098) But as Sqlsvr driver class is needed to use CakePHP with SQL server 2008, I got the driver file from follo
I have installed SQL Server 2008 Standard edition and I want to upgrade it to Developer version. I installed the Standard version for my MSDN subscription. I have tried to upgrade from the Standard ISO and Developer ISO and it does not give you an op
I often read that one purpose of a VIEW is security: to allow some users access to the underlying table, and other users to a derived view only. With that in mind I designed several views that supply restricted datasets to external users. All very fi
I have a sizable legacy MS SQL database where foreign key relationships were never implemented. Is it possible to implement "logical" foreign keys between entities in Entity Framework 4 without there being actual foreign key relationships presen
HEllo All, I am in a problem in my sql database.I have a DB in sql 2005.I just want to rename that DB and want it in sql 2008 without losing its data.For examble,i have a mdf and a ldf file of a DB named "Hello" in sql 2005 with a 1000 data,i wa
I am trying to insert a .csv file into SQL Server 2008 R2. The .csv is 300+MB from http://ipinfodb.com/ip_database.php Complete (City), 4.0M records. Here're the top 5 lines, with 1st line = column headers: "ip_start";"country_code";&q
I need to create trigger in SQL Server 2008 that gone insert all values from one row in which some value was changed into Log table! For example if i have table Employees that have column id, name , password, and i update this table and insert new va
I moved a VS Solution file from an old PC to a new PC. When I opened the solution in VS2010, I found that the database connections in database explorer was not present. Now I want the project to connect to a SQL Server database which is local to the