Passing a parameter through a SQL Server function [closed]

I am developing a local windows application that uses SQL Server. Each user has a login. There is also a store id. The user can login and be assigned their default store id but can also switch to other stores without having to logout so the store id can change.

Any records that are generated have a column for the store ID in all tables.

What I was hoping to do was the following.

Make the Store ID column a non null and set the Default Value or Binding to a SQL Function.

That SQL Function would retrieve the currently selected StoreID for insertion in the field.

What is the best way to ensure the StoreID is accurate? I could create a temp table that links the user id to the currently selected store ID. I am not well versed enough in SQL server to know if this is the best approach or if there is something much simpler. I have also tried searching but the results have been weak as its likely I am not sure how to couch my search terms in a manner that will return accurate results.

So far I have tried nothing, I am just wondering if this ia a feasible approach.

EDIT

Oh good point. In re-reading I realized StoreID is somewhat ambilvalent. Iny my case StoreID is just a way of identifying a store front. When the user logins they are assigned to a default store front. Any actions they perform are ascribed to their selected store front . Essentially each table has a StoreID column. Now, without logging out they can switch to a different store front. That storeid is retrieved from the main Store table. The storeid is simply stored in in a variable within the application. Anytime they insert or update to a table the StoreID has to be part of the query. I was just wondering if the StoreID field could be set to a DefaultValue that changes. It can by using a call to a function . But that function still has to somehow retreive the StoreID held as a variable in the application. Knowing my nature I will probably devise some huge, overblown method of accomplishing this task but I inevitably after I spend some time building , I discover someone has posted a very simple and elegant way to accomplish what has taken me too long to devise.

I am not sure how to improve clarity. But le me try.

I have a column in a table. That column requires a Default Value or Binding property. That Default Binding is linked to a Function like so

enter image description here

However that function requires an input, which would be the StoreID. The function cannot receive the input when called in this fashion as I do not think the action that occurs when the default value for the column is inserted can accept an external parameter.

5

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật