Select rows where price didn't change

Suppose you have a table like (am using SQL Server 2008, no audit log – table is HUGE): SecID | Date | Price 1 1/1/11 10 1 1/2/11 10 1 1/3/11 5 1 1/4/11 10 1 1/5/11 10 Suppose this table is HUGE (millions of rows for different secIDs and Date) – I would like […]

Pulling facebook and twitter status updates into a SQL database via Coldfusion Page

I’d like to set up a coldfusion page that will pull the status updates from my own facebook account and twitter accounts and put them in a SQL database along with their timestamps. Whenever I run this page it should only grab information after the most recent time stamp it already has within the database. […]

“Incorrect syntax near 'OFFSET'” modift sql comm 2012 to 2008

I’m listing questions with this SELECT q.qTitle, q.qDescription, q.qCreatedOn, u.uCode, u.uFullname, qcat.qcatTitle, q.qId, q.qStatus FROM tblQuestion AS q INNER JOIN tblUser AS u ON q.uId = u.uId INNER JOIN tblQuestionCategory AS qcat ON q.qcatId = qcat.qcatId WHERE (q.qStatus = 1) ORDER BY q.qCreatedOn DESC OFFSET @page*10 ROWS FETCH NEXT 10 ROWS ONLY But there is […]

Error: “Must declare the scalar variable” for insert statements in multiple database

I created a SQL script to add an entry in different database. However, when I run the script through SQL Server Management Studio. declare @address varchar(50) set @address = ‘Hope’ use DB1 go insert into Address values (@address) go use DB2 go insert into Address values (@address) go I got the following error: Must declare […]

SQL Server: How to find all localdb instance names

I have two versions (2012, 2014) of SQL Server Express LocalDB installed in my system. How can I find all existing LocalDB instance names? I found a way to do that using command line as mentioned in the answers section. Is there a better and easy way to do it?

SqlBulkCopy performance

I am working to increase the performance of bulk loads; 100’s of millions of records + daily. I moved this over to use the IDatareader interface in lieu of the data tables and did get a noticeable performance boost (500,000 more records a minute). The current setup is: A custom cached reader to parse the […]

In SQL Server, how to move/import a multiple .trc files to a trace table

I have a set of rollover .trc files recorded with Sql Profiler. mytrace.trc mytrace_1.trc mytrace_2.trc mytrace_3.trc I can import the first one using this command: use [my-database] SELECT * INTO trace_folder FROM::fn_trace_gettable(‘C:\mytrace.trc’, 4) However, this only appears to load the first file, not all four.

Insert into multiple tables

A brief explanation on the relevant domain part: A Category is composed of four data: Gender (Male/Female) Age Division (Mighty Mite to Master) Belt Color (White to Black) Weight Division (Rooster to Heavy) So, Male Adult Black Rooster forms one category. Some combinations may not exist, such as mighty mite black belt. An Athlete fights […]

Calling a stored procedure python

I am writing a script to pull info/update a MsSQL server and i can get my one stored procedure call to work but not my second one in the updateDB function. here is my code the script runs fine no error codes import pyodbc import json import argparse import cgi, cgitb #GLOBALS BUILDCODE = ” […]

sql search query for multiple optional parameters

I’m trying to write a query for an advanced search page on my document archiving system. I’m attempting to search by multiple optional parameters. I have about 5 parameters that could be empty strings or search strings. I know I shouldn’t have to check for each as a string or empty and create a separate […]

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