Avatar of Dirk Strauss
Dirk StraussFlag for South Africa asked on

Call Stored Procedure with Timestamp parameter

Good day

I have a stored procedure that looks as follows:

CREATE PROCEDURE [Local].[GetClientRecords] 
   @ClientId VARCHAR(50), 
   @Timestamp TIMESTAMP

Open in new window

The timestamp values will look as follows: 0x00000000000F1E1A

How do I call this stored procedure in SSMS for testing using EXEC. What do I pass for the @Timestamp parameter?

  • Must a date be passed in as stored procedure parameter and converted in the stored procedure to a timestamp and then used in the WHERE condition?

I have never used Timestamp as a parameter before, so I'm not sure how to use it in my stored procedure.

SQLMicrosoft SQL Server* Stored Proc

Avatar of undefined
Last Comment
Pavel Celba

8/22/2022 - Mon
Pavel Celba

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question

in postgres to_timestamp function is used
in MS SQL select convert(varchar,getdate(),23)  adjust 23 to another number to get the format you want
Pavel Celba

@MacNuttin Could you please explain how to use the CONVERT function to convert datetime into a timestamp which is worth to use in queries? I mean how to compare that value against timestamp columns in existing tables?

Of course, you may create a table containing 2 columns (datetime and timestamp) and insert a new row into this table every second (or use different interval interval of your choice). This table then contains info about the timestamp value at given time and such value is possible to use to retrieve rows updated before or after the given time.

Of course, we don't know what is the Dirk's intention...

Timestamps are used e.g. by Linq to detect possible row change before data saving. You may also remember the timestamp in your application and use such value to refresh local data buffers etc.

Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes