Quantcast
Channel: Transact-SQL forum
Browsing all 23857 articles
Browse latest View live

Change PK data length from VARCHAR(18) to VARCHAR(25)

Do techniques exist to change a PK data length? How can change the data length efficiently? This is due to a business rule change, a design to allow end-users to query the database, and not using...

View Article


Determine Days Since Last Visit

I think I may be overthinking this problem.What I have is a table that consists of membership data including visit dates. For each visit date, I need to determine the number of days since the last...

View Article


For varchar(max) should i use normarl update or .write in following situation.

Hi,     I want to update a col , which is null initially. It can be done it two way.I have to run UPDATE STMT  at many places becuase it keeps error history for the row sprated by | and :1)CREATE TABLE...

View Article

Image may be NSFW.
Clik here to view.

Grouping by month within date range

Hi,I have a date range which I like to group by months, but not from the 1st to last date of the calendar month but by given start date.  For example the table below represents the date range with some...

View Article

Schedule plan - Stored procedure

Hi Experts,I have a requirement like below....Any ideas to achieve the same will be highly appreciated...PLANStored Procedure to run on 3rd, 9th, 16th & 23rd every monthOn 3rd : delete data from...

View Article


SQL 2000 Convert multiple rows into one row and seperate it with comma

Hi AllI have a temp table on SQL 2000 getting populated on the fly as shown below.Clmname----------201401201403201404201405201406I need to use this resultset into one row as shown below and use this in...

View Article

Would like to convert Base64 string and convert it to an image in my TSQL.

I have a Base64 encoded string/image field in my SQL database.  I would like to take that string and convert it to an image. I know I need to use Convert.FromBase64String(mybase64string)  and set it to...

View Article

Replace Nulls with next row values for the same Id

Hi All,I have a table with 4 columns, let say ID,   Note1 , Note2  and  TypeID   Note1  Note2    Type 1        A       null      Good 1        A       null      Good 1        B       null      Good 1...

View Article


Count within a count and percentage

Hello,I am trying to get a percentage of work completed.  The below UNION query gives me the information I need but by the format.  Thanks for any help or direction/* counts total # of building that...

View Article


Need to find all the variable list within the procedure with there data type...

Need to find all the variable list within the procedure with there data type and assigned values.EFor e.g.procedure have 2 variables @a int ,@b varchar(100)set @a= id from t1set @b=name from t1the i...

View Article

Find intersections in date ranges and concatenate aggregated labels

Hello All,The original source of data will be a table of persons with their member ship: Description StartDate EndDate --------------------------------------------------- 18 Smith John Poker Club...

View Article

Find out SQL Server Logins and associated Server Roles

We have SQL Server 2000, 2005, 2008 and R2 in our environment.  We have several SQL Servers in our environment. I want to find out Server Logins and Server Roles Assigned in SQL Server. I want...

View Article

CREATE DATABASE AUDIT SPECIFICATION for all tables?

My task is to find out who is doing what to tables in a database that currently has wide open access. Can I create a database audit specification for all tables or do I have to write one for each...

View Article


Arithmetic overflow error

Hi all,The below is suppose to generate random dates but I receive the following error:  Msg 8115, Level 16, State 2, Line 7 Arithmetic overflow error converting expression to data type datetime.SQL...

View Article

CTE into a pivot

Hi AllI have a working query which attempts to find the top of a single table hierarchy nomatter how many levels it has.The query works a treat and returns the correct result as shown:--Working;WITH...

View Article


Convert Month to Range of Dates

Hi All,I need help it writing a T-SQL which converts a single month into the all the dates of that month.I tried and tried, and  nothing came to my brain. I need from experts like you.Table...

View Article

secure sql 2008 r2 backups

Hello, I've read through thishttp://technet.microsoft.com/en-us/library/ms190964(v=sql.105).aspxand besides managing AD accounts ACL I don't see anything else to protect sql backups. On Enterprise...

View Article


Conversion failed when converting varchar to data type int

Sorry to ask such a dumb question, but why can I not convert a varchar to int?Select [Index Name], count([adj count]) as 'total', cast([adj count] as int) as 'adj count'--, count([adj count]) as...

View Article

how to create a function with dynamic sql or any better way to achieve this?

        Hello,        I have created below SQL query which works fine however when scalar function created ,it        throws an error "Only functions and extended stored procedures can be executed from...

View Article

INNER Join Takes High Cost

Below piece of code, INNER Join is used 2 times and its costing High on execution plan andtakes more than 2 min to complete. is there a way to reduce the inner joins to speed up the store proc.. Please...

View Article
Browsing all 23857 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>