Tsql Questions


SQL Bulk import from CSV

I need to import a large csv file into an sql server. i'm using this : bulk insert csvtest from 'c:\csvfile.txt'

How to log in T-SQL

I'm using ado.net to access sql server 2005 and would like to be able to log from inside the t-sql stored procedures that i'm calling. is that

Dishes database relations

I want to create database with recipes. how it should look like? for example let it exist two recipes: first recipe: 2 eggs with


I am trying to union all two tables 1) current receipts 2) historical receipts. both of those tables have cte because it was the only way how

Get last item in a table - SQL

I have a history table in sql server that basically tracks an item through a process. the item has some fixed fields that don't change throughout

split string in sql

I have following text banker's xxxx yyyy~#0018800~mmmmm~0401 from sql table i need to filter only 0018800 from the text in

Update XML column in T-SQL

I want to replace part of an xslt file stored in a xml column in a sql server database table. i tried updating the entire

T-SQL Select MAX from subquery

I've got the following tables in a database. we have product which have multiple products for a series, and we have productvariation which has

Find duplicate data in last 1 hour

I am looking for a sql script to find the data which has more than 2 entries in last 1 hour. i have a table having user_id & event_time. i

Compare data from 2 tables

I'm not sure if the title of this post is correct but i don't have any other idea ;) i've got 2 tables - documents and

Extracting Related XML Component

I've got the below xml where i'm successfully exporting all the values from the cmpd nodes. where i'm getting stuck however, is how can i extract

SQL insert error

Below code saying error incorreect syntax near "main" insert into tbl ( 'week', main, a, b, c,


I have this query that works fine. it selects rows into the sy.useroptions table for the ‘jeff’ user. however, i created another query

T-SQL recursive update

What query should i use to update total and total_previous columns when i update income or outcome value for account. mind that record are sorted

Blog Categories