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

COnverting COlumn Data Type from Varchar to Date

I have DATA in text file, which when i try to import into SQL table the data type for the DATA column comes a s Varchar.  I want this Date Column DATA type to be Date. I tried Converting the DATA type...

View Article


get the half of the year (like quarter)

Hi guys, I need to get the "half" of the year. I am using the following... CaseWhenCAST(DATEPART(quarter, Stock.VALUEDATE)asint)= 1 then'1'WhenCAST(DATEPART(quarter, Stock.VALUEDATE)asint)= 2...

View Article


Transferring data from SQL to Excel

Getting an error emssage on Executing following command "EXEC proc_generate_excel_with_columns4 '[servername]', '[tablename]','[path of the file]'"

View Article

Best Solution for IDENTITY Skipping 1000

Is there a good solution/workaround for IDENTITY skipping 1000 values like below?ID168 169 170 1161 1162 1163Thanks.Kalman Toth Database & OLAP Architect SQL Server 2014 Design & ProgrammingNew...

View Article

more help with a where clause where I have to filter out states

I asked the same question yesterday and think I got most of the answer, but now I can't get it to work completly so I ask again with a more concrete example, scripts etc. (one of the posters also asked...

View Article


ignore query hints?

Is there a way to ignore all query hints? SQL 2008 R2. Thank youPaula

View Article

Stored Procedure

I Have a Stored procedure like below USE [AfmsBizTalkAggregationDb] GO /****** Object:  StoredProcedure [dbo].[InsertUnitItem]    Script Date: 06/25/2014 22:11:23 ******/ SET ANSI_NULLS ON GO SET...

View Article

Issue: Randomly sql server resets sequence to a lower value

Randomly sql server resets sequence to a lower valueAnd this is the definition of the sequence:CREATE SEQUENCE [dbo].[seqPJob]  AS [bigint] START WITH 1 INCREMENT BY 1 MINVALUE 0 MAXVALUE...

View Article


how to show parentid only in front of first child

Hi,   following query is from msdnhttp://technet.microsoft.com/en-us/library/ms190766(v=sql.90).aspxUSE AdventureWorks; GO WITH Sales_CTE (SalesPersonID, NumberOfOrders, MaxDate) AS ( SELECT...

View Article


Image may be NSFW.
Clik here to view.

Query help

Hi I have a table like:DECLARE @Employee Table(Title varchar(10),Name varchar(50),Level int) INSERT INTO @Employee VALUES ('Admin','Dave',2) INSERT INTO @Employee VALUES ('Engineer1','Allysis',4)...

View Article

Convert Columns data into rows for the same ID

Hi All,I have a table with 5 columns , let say  ID1,ID2,ExtID,ID3 and TypesMy source data looks like this.. ID1              ID2         ExtID       ID3       Types              3255413    11988012...

View Article

Help with SQL Script please

Hi there,What I`m trying to accomplish here is the following guys;This would be the pseudo code that I`m trying to convert into proper SQL;Declare @Parameter varchar(50)now I`m trying to find out how...

View Article

Integer Variable with value 0 is entering IF loop where varibale is checked...

Hi All,Variable with value 0 enters the loop when checked for blank value. Example:---case 1:- when variable is checked with blank value DECLARE @var1 INT SET @var1=0IF (@var1='') BEGIN select @var1...

View Article


How to fill empty cells with previous non empty value?

Hello rows where cat=2 do not have price and i want to fill it with previous value wich cat=1 for every itemTable named tbid        item_no     price         cat 1           I1             5...

View Article

Merging columns in SQL query based on the certain criteria

Hi,I find query below:SELECT AL1.BILL_NO as "Bill No", AL3.MAIN_TYPE as "Main Type", AL3.BILL_NO as "Bill No", AL3.SUB_TYPE as "Sub Type", AL3.AMOUNT as "Amount", AL2.PAY_ID as "Pay ID"FROM TABLE1 AL1,...

View Article


Query

Below I have the following query which will show all id_number that have a creation date greater than the last day.  I'm looking to tweak the query as it sits looking back at the last day.  It is...

View Article

@@Identity not returning newly Inserted record ID

Hi Guys I am working with user to resolve issue since i am not t-sql guy but hope i can find solution here.in one one of Database Insert After trigger is set up... This trigger fires up when new record...

View Article


SQL Query Help

Hi, I have 2 tables. First table has 10 columns as belowcol1 col2 col3 col4 col5 col6 col7 col8 col9 col10Other tables is like belowColumn1  condition1   value1     column2     condition2      value2...

View Article

Weird SQL server cursor issue

Hi All.I have a stored procedure which can be seen below. The way it should work is that it should loop through a lot of all the databases on the SQL instance and pass the details onto another stored...

View Article

converting money datatype to varchar with out rounding the value

Hi,I am looking forward for the way to cast/convert 'money' datatype to 'varchar' with out rounding the value.I like to get the value in varchar as in money.

View Article
Browsing all 23857 articles
Browse latest View live


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