Connect different Windows User in SQL Server Management Studio (2005 or later)

Is there a way in SQL Server Management Studio 2005 (or later) to change the Windows Authentication user (as you could in SQL Server 2000 and older)? This is the general connection properties dialog(note the greyed out UID/PWD when selecting Windows Auth): FYI – One workaround is to use runas but I’m looking for a … Read more

How can I select the first day of a month in SQL?

I just need to 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)) + “https://stackoverflow.com/” + CAST(MONTH(@mydate) AS VARCHAR(2)) + ‘/01’ AS DATETIME) But unfortunately, this is not very elegant, and not very fast either. Is … Read more

Select statement to find duplicates on certain fields

Can you help me with SQL statements to find duplicates on multiple fields? For example, in pseudo code: select count(field1,field2,field3) from table where the combination of field1, field2, field3 occurs multiple times and from the above statement if there are multiple occurrences I would like to select every record except the first one. 8 Answers … Read more