Skip to content

Tag: sql-server

MS SQL Server Date Month Output

SQL will output a month part as a number but I’d like to out put the 3 char version (Jan, Feb, Mar etc) My query thus far is Answer For each DBMS the way is different Here are few 4 DBMS’s MS SQL Server MySQL Postgresql Oracle So in your case use the appropriate date field instead of current date

SQL Server INNER JOIN and GROUP BY

In sql server I’m trying to group by each sales people some infos as follow: I have 2 tables: Positions and Clients In Positions table, I have the following columns: Client_Id, Balance, Acquisition_Cost and in the Clients table I use the following columns: Client_Id and Sales_person. I want to group by …

Exclude specific rows from table in Stored Procedure

I have a table named Blacklist and table named Order. Both have CustomerId column. Stored Procedure ExecOrder manipulates Order table. My goal is to exclude Orders that have Blacklisted CustomerId (meaning : Order’s CustomerId is in Blacklist table). I edited ExecOrder SP like this: @Temp table returns …

Select * into #Temp not working in dynamic SQL

When I create a temporary table and insert data into that temporary table through dynamic SQL its work fine. But when I use select * into #TempTable1 from YourTable in dynamic SQL it throw error. I am unable to understand the cause of this error. Table: Working Code:- Not Working Code: Error: Msg 208 Level 16…