sql-server-2008 Questions

9

Solved

My code is like shown below : select col1,count(col2) as col7 from --some join operation group by col1 having col7 >= 3 -- replace col7 by count(col2) to make the code work My code causes the...
Vanessa asked 27/12, 2012 at 2:26

5

I am writing a sql script for dropping column and a default constraint. The following script works fine but i like to know if it is a right way of doing it. Can i drop a default constraint with a...
Mightily asked 17/12, 2013 at 9:40

3

Solved

While researching the use of Table Hints, I came across these two questions: Which lock hints should I use (T-SQL)? What effect does HOLDLOCK have on UPDLOCK? Answers to both questions say that...
Starch asked 21/10, 2011 at 0:12

7

Solved

I've seen a few of these questions asked but haven't spotted one that's helped!! I'm trying to select the first part of a postcode only, essentially ignoring anything after the space. the code I am...
Stagy asked 28/6, 2013 at 15:14

6

The Situation We have an application where we store machine settings in a SQL table. When the user changes a parameter of the machine, we create a "revision", that means we insert a row into a tab...
Kutch asked 28/1, 2015 at 14:23

6

Solved

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 ...
Orgel asked 2/9, 2013 at 8:10

4

I am trying to pass in a user defined table type into a query in C#. the type is defined with 2 columns (org and sub org) this is what my code looks like: DataSet ds = new DataSet(); try { Dat...
Consentaneous asked 23/7, 2013 at 18:19

47

Solved

SELECT GETDATE() Returns: 2008-09-22 15:24:13.790 I want that date part without the time part: 2008-09-22 00:00:00.000 How can I get that?
Sanctus asked 22/9, 2008 at 3:31

4

Solved

I'm trying to create a view where I want a column to be only true or false. However, it seems that no matter what I do, SQL Server (2008) believes my bit column can somehow be null. I have a table...
Lillian asked 24/2, 2010 at 14:47

16

Solved

I have a need to create a function the will return nth element of a delimited string. For a data migration project, I am converting JSON audit records stored in a SQL Server database into a struc...
Concussion asked 18/10, 2013 at 12:18

16

Solved

I am trying to compare two tables, SQL Server, to verify some data. I want to return all the rows from both tables where data is either in one or the other. In essence, I want to show all the discr...
Splashy asked 16/1, 2010 at 15:22

35

Solved

How can one select the first day of the month of a given DateTime variable? I know it's quite easy to do using this kind of code: select CAST(CAST(YEAR(@mydate) AS VARCHAR(4)) + '/' + CAST(MONTH(...
Dougald asked 5/10, 2009 at 15:30

4

Solved

Below is a subset of the kind of table structure and data i'm working with. CREATE TABLE #Test ( Val varchar(5) ,Type varchar(5) ) INSERT #Test VALUES ('Yes','Text') INSERT #Test VALUES ('10','...
Backward asked 31/10, 2012 at 15:20

8

Solved

Is it possible to install Management Studio by itself, and if so, is there a separate download/install exe for it?
Stalagmite asked 11/8, 2010 at 15:11

5

Solved

I have following table. Table A: ID ProductFK Quantity Price ------------------------------------------------ 10 1 2 100 11 2 3 150 12 1 1 120 ---------------------------------------------- I ne...
Tips asked 25/10, 2015 at 8:51

10

Solved

How can I specify an input sql file with a long query when using bcp? I tried using the -i option but it keeps complaining about a command-line error with no extra information. Is this possible?
Brut asked 13/5, 2012 at 2:54

9

Solved

I currently have a table Telephone it has entries like the following: 9073456789101 +773456789101 0773456789101 What I want to do is remove only the 9 from the start of all the entries that have...
Azotize asked 31/7, 2013 at 15:17

33

Solved

I need to add a specific column if it does not exist. I have something like the following, but it always returns false: IF EXISTS(SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'myT...

2

I need a way to audit when someone attempts to either ENABLE or DISABLE a trigger in our database. The DDL trigger alternative works great but only under the condition for when the user uses ALTE...
Erdda asked 24/10, 2011 at 14:6

5

Solved

I have a scenario where i'm splitting a number of results into quartilies using the SQL Server NTILE function below. The goal is to have an as equal number of rows in each class case NTILE(4) over...
Staceestacey asked 17/2, 2012 at 16:3

18

Solved

I'm trying to write a script that will completely empty a SQL Server database. This is what I have so far: USE [dbname] GO EXEC sp_msforeachtable 'ALTER TABLE ? NOCHECK CONSTRAINT all' EXEC sp_msf...
Fasces asked 9/12, 2011 at 0:30

12

Solved

How to drop a column which is having Default constraint in SQL Server 2008? My query is alter table tbloffers drop column checkin I am getting below error ALTER TABLE DROP COLUMN checkin fa...
Wellnigh asked 27/12, 2011 at 6:55

17

Solved

I am trying to drop a table but getting the following message: Msg 3726, Level 16, State 1, Line 3 Could not drop object 'dbo.UserProfile' because it is referenced by a FOREIGN KEY constraint. ...
Engulf asked 6/7, 2013 at 10:4

2

Solved

Is there any way to compare two strings in SQL Server 2008 stored procedure like below? int returnval = STRCMP(str1, str2) returns 0 if the strings are the same returns -1 if the first argument...
Mejias asked 8/7, 2011 at 11:31

10

Solved

I need to calculate the difference of a column between two lines of a table. Is there any way I can do this directly in SQL? I'm using Microsoft SQL Server 2008. I'm looking for something like thi...
Euryale asked 2/4, 2009 at 15:28

© 2022 - 2025 — McMap. All rights reserved.